:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #090d16;
  --bg-card: #111827;
  --bg-card-header: #161f33;
  --bg-card-subtle: #1a2336;
  --bg-input: #0f172a;
  --border-color: #243147;
  --border-focus: #f43f5e;

  --text-main: #f8fafc;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --primary-color: #f43f5e;
  --primary: #f43f5e;
  --primary-light: rgba(244, 63, 94, 0.14);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-header: #f1f5f9;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #e11d48;

  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary-color: #e11d48;
  --primary: #e11d48;
  --primary-light: #ffe4e6;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, .brand-title, .panel-title, .tool-hero-title {
  font-family: var(--font-heading);
}

.mono {
  font-family: var(--font-mono);
}

.tool-layout {
  width: 100%;
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

@media (min-width: 1536px) {
  .tool-layout {
    max-width: 1580px;
  }
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-hero-box,
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.hero-header-badge {
  display: inline-flex;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.tool-hero-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.3rem, 2.4vw, 1.75rem);
  line-height: 1.25;
}

.tool-hero-subtitle {
  margin: 0 0 1.2rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.quick-label {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chip-preset {
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 36px;
}

.chip-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.builder-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .builder-grid {
    grid-template-columns: 1fr;
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.panel-title {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
}

.panel-header .panel-title {
  margin-bottom: 0.2rem;
}

.panel-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 1rem;
  min-width: 0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 560px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input,
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.94rem;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.form-select option {
  background-color: var(--bg-card);
  color: var(--text-primary);
}

.allergens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.55rem;
}

.allergen-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 500;
  min-height: 42px;
  user-select: none;
  transition: all 0.15s ease;
}

.allergen-chip input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.allergen-chip.is-selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--text-primary);
  font-weight: 600;
}

.toggles-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.toggle-card {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.toggle-card input {
  margin-top: 0.2rem;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.toggle-card strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
}

.toggle-card span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Tarjeta visual de alto contraste (siempre fondo claro nítido para mostrar en restaurantes) */
.allergy-card-visual {
  background: #ffffff;
  color: #0f172a;
  border-radius: 14px;
  border: 2px solid #dc2626;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.allergy-card-visual.is-mild {
  border-color: #d97706;
}

.card-severity-banner {
  background: #dc2626;
  color: #ffffff;
  padding: 0.9rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.08rem;
  line-height: 1.3;
}

.allergy-card-visual.is-mild .card-severity-banner {
  background: #d97706;
}

.card-body-visual {
  padding: 1.2rem;
}

.card-intro-target {
  margin: 0 0 0.9rem;
  font-size: 1.08rem;
  line-height: 1.5;
  font-weight: 600;
  color: #0f172a;
}

.card-allergens-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.95rem;
}

.card-allergen-badge {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 0.42rem 0.75rem;
  font-weight: 700;
  font-size: 0.96rem;
}

.card-cross-target {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.9rem;
  background: #fff7ed;
  border-left: 4px solid #ea580c;
  color: #7c2d12;
  font-size: 0.95rem;
  line-height: 1.45;
  font-weight: 600;
  border-radius: 0 6px 6px 0;
}

.card-thanks-target {
  margin: 0;
  font-size: 0.94rem;
  color: #334155;
  font-weight: 600;
}

.card-personal-meta {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px dashed #cbd5e1;
  font-size: 0.84rem;
  color: #475569;
  font-weight: 600;
}

.card-spanish-ref {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.45;
}

.card-spanish-ref .ref-label {
  font-weight: 700;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.card-spanish-ref p {
  margin: 0;
}

.actions-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 1rem;
}

@media (min-width: 600px) {
  .actions-bar {
    grid-template-columns: repeat(3, 1fr);
  }
}

.btn-primary,
.btn-secondary {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: 0;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--primary);
}

.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.94);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow-y: auto;
}

.fullscreen-overlay.is-open {
  display: flex;
}

.fullscreen-inner {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.btn-close-fullscreen {
  align-self: flex-end;
  background: #1e293b;
  color: #ffffff;
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
}

.fullscreen-card .headline-target {
  font-size: 1.35rem;
}

.fullscreen-card .card-intro-target {
  font-size: 1.3rem;
}

.fullscreen-card .card-allergen-badge {
  font-size: 1.15rem;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
}

.faq-question {
  padding: 1rem 1.15rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-weight: 600;
  list-style: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-item[open] .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 1.15rem 1rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
}

.faq-answer p {
  margin: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1200;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.modal-header,
.modal-footer {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-footer {
  border-bottom: 0;
  border-top: 1px solid var(--border-color);
  justify-content: flex-end;
}

.modal-title {
  margin: 0;
  font-size: 1.05rem;
}

.modal-body {
  padding: 1.15rem 1.25rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.btn-modal-close {
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

@media print {
  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .tool-hero-box,
  .config-panel,
  .actions-bar,
  .faq-section,
  .related-tools-section,
  .fijate-footer {
    display: none !important;
  }
  body {
    background: #ffffff !important;
  }
  .tool-layout,
  .tool-with-sidebar,
  .tool-main-content,
  .builder-grid,
  .preview-panel {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  .preview-panel .panel-header {
    display: none !important;
  }
  #allergy-card-printable {
    max-width: 160mm;
    margin: 15mm auto;
    box-shadow: none !important;
  }
}
