:root {
  --navy: #03244d;
  --orange: #DD550C;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --cs: #3b82f6;
  --cs-blue: #3b82f6;
  --ps: #22c55e;
  --ps-green: #22c55e;
  --gov: #eab308;
  --gov-yellow: #eab308;
  --dwl: #ef4444;
  --dwl-red: #ef4444;
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 1.5rem;
  max-width: 1240px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; flex-direction: column; gap: 1rem; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* HEADER */
.header-bar {
  background: var(--navy);
  color: var(--white);
  padding: 0.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-bar .logo { font-weight: 700; font-size: 0.9rem; letter-spacing: 0.02em; }
.header-bar .progress { font-size: 0.8rem; opacity: 0.8; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: #c44a0a; }
.btn-secondary { background: var(--navy); color: var(--white); }
.btn-secondary:hover { background: #051c3b; }
.btn-outline { background: transparent; border: 2px solid var(--navy); color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: var(--white); }
.btn-sm { padding: 0.45rem 0.95rem; font-size: 0.85rem; }
button:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }

/* SCREEN 0: TOPIC PICKER */
#screen-0 {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: linear-gradient(135deg, var(--navy) 0%, #0a3a6b 100%);
  color: var(--white);
  min-height: 100vh;
  max-width: 100%;
  padding: 2rem;
  gap: 1.5rem;
}
#screen-0 h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); font-weight: 800; line-height: 1.1; }
#screen-0 h1 span { color: var(--orange); }
#screen-0 .subtitle { font-size: clamp(1rem, 2vw, 1.25rem); opacity: 0.85; max-width: 640px; line-height: 1.6; }
#screen-0 .badge {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 2rem;
  padding: 0.4rem 1.2rem;
  font-size: 0.85rem;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 880px;
  margin-top: 0.75rem;
}
.topic-card {
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  text-align: left;
  color: var(--white);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  backdrop-filter: blur(4px);
}
.topic-card:hover {
  border-color: var(--orange);
  background: rgba(255,255,255,0.10);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.25);
}
.topic-card-chapter {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--orange);
  font-weight: 600;
}
.topic-card-label {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1.1;
  margin: 0.1rem 0 0.2rem;
}
.topic-card-blurb {
  font-size: 0.92rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.85);
}
.topic-card-markets {
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(255,255,255,0.65);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 0.55rem;
  margin-top: 0.2rem;
}
.topic-card-markets strong {
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}
.topic-card-cta {
  margin-top: auto;
  align-self: flex-start;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: 0.02em;
  padding-top: 0.4rem;
}

/* SCREEN 1: MARKET PICKER */
#screen-1 { gap: 1rem; padding-top: 1rem; }
#screen-1 h2 { color: var(--navy); font-size: 1.5rem; text-align: center; }
.instruction { text-align: center; color: var(--gray-500); margin-bottom: 0.5rem; }

.market-grid {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.market-cat {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.market-cat-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.85rem;
  background: var(--white);
  border-radius: var(--radius);
  border-left: 4px solid;
  box-shadow: var(--shadow);
}
.market-cat-consumer-bears .market-cat-header { border-left-color: var(--cs); }
.market-cat-producer-bears .market-cat-header { border-left-color: var(--ps); }
.market-cat-mixed          .market-cat-header { border-left-color: var(--gov); }
.market-cat-label {
  color: var(--navy);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}
.market-cat-blurb {
  color: var(--gray-700);
  font-size: 0.85rem;
  line-height: 1.5;
}
.market-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.market-card-elast {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--gray-500);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.market-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
  font-family: inherit;
  color: inherit;
  min-height: 160px;
}
.market-card:hover {
  border-color: var(--orange);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.market-card.selected {
  border-color: var(--orange);
  background: #fff7ed;
  box-shadow: 0 0 0 3px rgba(221,85,12,0.18);
}
.market-card-label { font-size: 1.15rem; font-weight: 700; color: var(--navy); }
.market-card-hook  { font-size: 0.82rem; color: var(--orange); font-weight: 600; }
.market-card-question { font-size: 0.88rem; color: var(--gray-700); line-height: 1.4; margin-top: auto; }

/* SCREEN 2: LAB */
.lab-header {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.1rem 1.4rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--orange);
}
.lab-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.lab-header .lab-question {
  color: var(--navy);
  font-size: 1.3rem;
  margin-bottom: 0.4rem;
  line-height: 1.3;
  flex: 1;
}
.lab-header .lab-context {
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.55;
}

/* MODE TOGGLE */
.mode-toggle {
  display: inline-flex;
  background: var(--gray-100);
  border-radius: 999px;
  padding: 0.18rem;
  flex-shrink: 0;
}
.mode-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--gray-700);
  transition: all 0.18s;
}
.mode-btn.active {
  background: var(--navy);
  color: var(--white);
  box-shadow: var(--shadow);
}

.lab-main {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 1rem;
}

.lab-graph-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.graph-container {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0.9rem;
  box-shadow: var(--shadow);
  min-height: 380px;
}
.graph-container svg { width: 100%; height: 100%; }

.graph-caption {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
  box-shadow: var(--shadow);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--gray-700);
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.graph-caption:empty { display: none; }
.graph-caption .eq-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
}
.graph-caption .eq-label {
  color: var(--gray-500);
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  margin-right: 0.35rem;
  font-family: var(--font-sans);
}
.graph-caption strong {
  color: var(--navy);
  font-weight: 700;
}
.graph-caption .eq-pre  strong { color: var(--gray-700); }
.graph-caption .eq-post strong { color: var(--orange); }

.lab-presets-row {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  box-shadow: var(--shadow);
}
.lab-presets-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.45rem;
}
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.preset-chip {
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: 1.5rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: var(--navy);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s;
}
.preset-chip:hover { border-color: var(--orange); background: #fff7ed; }
.preset-chip.selected { background: var(--orange); color: var(--white); border-color: var(--orange); }

.preset-blurb {
  background: #fefce8;
  border-left: 4px solid var(--gov-yellow);
  padding: 0.7rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  color: var(--gray-700);
  line-height: 1.5;
  display: none;
}
.preset-blurb:not(:empty) { display: block; }

/* WELFARE PANEL */
.welfare-panel-wrap {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.welfare-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}
.welfare-title small { font-size: 0.75rem; text-transform: none; letter-spacing: 0; color: var(--gray-500); display: block; font-weight: 400; margin-top: 0.15rem; }

.welfare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--gray-700);
  padding: 0.18rem 0;
}
.welfare-emph {
  background: var(--gray-100);
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  margin-top: 0.3rem;
  font-weight: 600;
}
.welfare-label { flex: 1; min-width: 0; padding-right: 0.5rem; }

.reveal {
  background: transparent;
  border: 1px dashed var(--gray-300);
  border-radius: 6px;
  padding: 0.18rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  position: relative;
  min-width: 80px;
  text-align: right;
  transition: all 0.15s;
}
.reveal:hover { border-color: var(--orange); background: #fff7ed; }
.reveal-placeholder {
  letter-spacing: 0.15em;
  color: var(--gray-300);
  user-select: none;
}
.reveal-value { display: none; color: var(--navy); }
.reveal.revealed .reveal-placeholder { display: none; }
.reveal.revealed .reveal-value { display: inline; }
.reveal.revealed { border-style: solid; border-color: var(--orange); background: #fff7ed; }

.welfare-hint {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-style: italic;
  margin-top: 0.4rem;
  line-height: 1.4;
}
.region-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.5rem;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--gray-200);
  font-size: 0.75rem;
  color: var(--gray-700);
}
.region-key {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 2px 4px;
  border-radius: 5px;
  transition: background 120ms ease, outline 120ms ease;
}
.region-key[data-region] {
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 1px;
}
.region-key[data-region]:hover,
.region-key[data-region]:focus-visible {
  background: var(--gray-100);
  outline-color: var(--navy);
}
.region-key.pinned-region {
  background: rgba(3,36,77,0.08);
  outline-color: var(--navy);
}
.key-letter {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 4px;
  font-weight: 800;
  font-family: var(--font-mono);
  text-align: center;
  line-height: 18px;
  font-size: 0.75rem;
  flex-shrink: 0;
}
/* Per-letter swatches — match polygon fill colors. */
.region-key-a .key-letter { background: rgba(245,158,11,0.40);  color: #78350f; }
.region-key-b .key-letter { background: rgba(251,113,133,0.40); color: #881337; }
.region-key-c .key-letter { background: rgba(6,182,212,0.40);   color: #0e4a5b; }
.region-key-d .key-letter { background: rgba(127,29,29,0.55);   color: #fef2f2; }

/* Welfare rows that map to a region get a subtle pointer cue. */
.reveal[data-regions]:not([data-regions=""]) { cursor: pointer; }
.reveal.pinned-region { outline: 2px solid var(--navy); outline-offset: 1px; }

/* LAB CONTROLS */
.lab-controls {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1fr;
  gap: 1rem;
}
.lab-slider-block,
.lab-format-block,
.lab-elasticity-block,
.lab-ceiling-block {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow);
}
.lab-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.lab-slider-title { font-weight: 600; color: var(--navy); font-size: 0.9rem; }
.lab-slider-val {
  background: var(--orange);
  color: var(--white);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
}
input[type="range"] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--gray-200);
  border-radius: 4px;
  margin: 0.25rem 0;
}
input[type="range"]:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  background: var(--orange);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  border: 2px solid var(--white);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  background: var(--orange);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--white);
}
.lab-slider-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--gray-500);
  font-family: var(--font-mono);
}
.lab-slider-units {
  text-align: center;
  font-size: 0.72rem;
  color: var(--gray-500);
  font-style: italic;
  margin-top: 0.3rem;
}

.lab-row-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

.format-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.elasticity-row { margin-top: 0.5rem; }
.elasticity-row label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--navy);
  font-weight: 600;
}
.elasticity-row label .value {
  background: var(--gray-100);
  color: var(--orange);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.elasticity-callout {
  background: #f0f9ff;
  border-left: 4px solid var(--cs-blue);
  padding: 0.5rem 0.7rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.78rem;
  color: var(--gray-700);
  line-height: 1.4;
  margin-top: 0.5rem;
}
.elasticity-realworld {
  background: #fef9c3;
  border-left: 4px solid var(--gov-yellow);
  padding: 0.5rem 0.7rem;
  border-radius: 0 6px 6px 0;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--gray-700);
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.elasticity-realworld:empty { display: none; }
.elasticity-realworld .rw-title {
  font-family: var(--font-sans);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 0.1rem;
}
.elasticity-realworld .rw-row {
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
}
.elasticity-realworld .rw-tag {
  font-family: var(--font-mono);
  color: var(--orange);
  font-weight: 700;
  flex-shrink: 0;
  min-width: 30px;
}
.elasticity-realworld .rw-text {
  flex: 1;
}

.ceiling-slider-row {
  margin-top: 0.5rem;
}

/* QUIZ */
.quiz-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow);
  margin-top: 0.5rem;
}
.quiz-title {
  color: var(--navy);
  font-size: 1.05rem;
  margin-bottom: 0.8rem;
}
.quiz-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.quiz-card {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--gray-300);
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: auto auto auto;
  grid-column-gap: 0.5rem;
  grid-row-gap: 0.5rem;
}
.quiz-num {
  grid-column: 1; grid-row: 1 / span 3;
  font-weight: 700;
  color: var(--orange);
  font-family: var(--font-mono);
}
.quiz-prompt {
  grid-column: 2; grid-row: 1;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--gray-900);
}
.quiz-body {
  grid-column: 2; grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.quiz-feedback {
  grid-column: 2; grid-row: 3;
  font-size: 0.85rem;
  line-height: 1.45;
  margin-top: 0.3rem;
}
.quiz-feedback:empty { display: none; }
.quiz-feedback.correct { color: #15803d; }
.quiz-feedback.incorrect { color: #b91c1c; }
.quiz-mark { font-weight: 800; font-size: 1.1rem; margin-right: 0.3rem; }

.quiz-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--gray-700);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  transition: background 0.12s;
}
.quiz-option:hover { background: var(--gray-100); }

.quiz-numeric-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.quiz-numeric-input {
  font-family: var(--font-mono);
  border: 1.5px solid var(--gray-300);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.95rem;
  width: 140px;
}
.quiz-numeric-input:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 1px;
  border-color: var(--orange);
}
.quiz-numeric-units { color: var(--gray-500); font-size: 0.85rem; }

.quiz-submit { align-self: flex-start; margin-top: 0.3rem; }
.quiz-set-state { align-self: flex-start; }

.result-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* RESPONSIVE */
@media (max-width: 980px) {
  .lab-main { grid-template-columns: 1fr; }
  .lab-controls { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .screen { padding: 1rem; }
  .market-grid { grid-template-columns: 1fr; }
  .lab-controls { grid-template-columns: 1fr; }
  .quiz-card { grid-template-columns: 28px 1fr; }
  .header-bar { padding: 0.5rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* FEEDBACK BUTTON + MODAL */
.feedback-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 90;
  background: var(--orange);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.2rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.18s, background 0.18s, box-shadow 0.18s;
}
.feedback-btn:hover {
  background: #c44a0a;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.22);
}
.feedback-btn:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 3px;
}
.feedback-btn-icon { font-size: 1rem; line-height: 1; }

.feedback-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.feedback-modal[hidden] { display: none; }
.feedback-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  animation: fadeIn 0.18s ease;
}
.feedback-card {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  max-width: 540px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: fadeIn 0.22s ease;
}
.feedback-close {
  position: absolute;
  top: 0.75rem;
  right: 0.95rem;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--gray-500);
  padding: 0.2rem 0.5rem;
  font-family: inherit;
  border-radius: 6px;
}
.feedback-close:hover { color: var(--navy); background: var(--gray-100); }
.feedback-card h2 { color: var(--navy); font-size: 1.2rem; margin: 0; padding-right: 1.5rem; }
.feedback-sub { color: var(--gray-700); font-size: 0.85rem; line-height: 1.45; margin: 0; }
.feedback-cat {
  display: flex;
  gap: 0.95rem 1rem;
  flex-wrap: wrap;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.5rem 0.85rem 0.6rem;
  margin: 0;
}
.feedback-cat legend {
  padding: 0 0.4rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
}
.feedback-cat label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--gray-700);
  cursor: pointer;
}
.feedback-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: -0.4rem;
}
#feedback-text {
  width: 100%;
  border: 1.5px solid var(--gray-300);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 120px;
}
#feedback-text:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 1px;
  border-color: var(--orange);
}
.feedback-context {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  color: var(--gray-700);
}
.feedback-context summary {
  cursor: pointer;
  color: var(--gray-500);
  font-size: 0.78rem;
  list-style: none;
}
.feedback-context summary::-webkit-details-marker { display: none; }
.feedback-context summary::before {
  content: '▸ ';
  color: var(--gray-400);
}
.feedback-context[open] summary::before { content: '▾ '; }
.feedback-context pre {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--gray-700);
  margin-top: 0.55rem;
  white-space: pre-wrap;
  background: var(--gray-50);
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  max-height: 160px;
  overflow-y: auto;
}
.feedback-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}
.feedback-hint {
  font-size: 0.72rem;
  color: var(--gray-500);
  text-align: center;
  line-height: 1.4;
  margin: 0;
}
.feedback-hint a { color: var(--orange); font-weight: 600; }
.feedback-hint em { font-style: normal; font-weight: 600; color: var(--gray-700); }
.feedback-toast {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 250;
  background: var(--navy);
  color: var(--white);
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  font-size: 0.82rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  animation: fadeIn 0.18s ease;
}
.feedback-toast[hidden] { display: none; }

@media (max-width: 640px) {
  .feedback-btn { bottom: 1rem; right: 1rem; padding: 0.55rem 0.95rem; font-size: 0.78rem; }
  .feedback-card { padding: 1.2rem; }
  .feedback-actions { flex-direction: column-reverse; }
  .feedback-actions .btn { width: 100%; }
}
