* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --grenat: #7a0026;
  --g6: #8c173a;
  --g3: #c27a96;
  --g1: #f7eef2;
  --ink: #111111;
  --mut: #5a6370;
  --bg: #fff7e6;
  --card: #faf9fb;
  --card-2: rgba(255,255,255,0.88);
  --shd: 0 8px 28px rgba(0, 0, 0, 0.08);
  --r: 22px;
  --moutarde: #e6b656;
  --moutarde-pale: #f8e3b7;
  --moutarde-tres-pale: #fff7e6;
  --vert: #2f855a;
  --rose: #f6e7ed;
  --sf: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --garamond: "EB Garamond", Garamond, "Times New Roman", serif;
}

html, body {
  min-height: 100%;
}

body {
  font-family: var(--garamond);
  background:
    radial-gradient(circle at top right, rgba(122,0,38,0.06), transparent 22%),
    radial-gradient(circle at left bottom, rgba(230,182,86,0.18), transparent 24%),
    var(--moutarde-tres-pale);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  padding-bottom: 84px;
}

.ios-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(250, 249, 251, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-btn {
  background: rgba(122, 0, 38, 0.08);
  border: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grenat);
  cursor: pointer;
  transition: 0.2s ease;
}

.menu-btn:hover {
  background: rgba(122, 0, 38, 0.16);
}

.menu-btn svg,
.drawer-item svg,
.card-title svg,
.small-title svg,
.mini-icon svg,
.footer .icn svg,
.drawer-header svg {
  width: 20px;
  height: 20px;
}

.header-title {
  font-size: 1.8rem;
  color: var(--grenat);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subline,
.header-sub {
  font-family: var(--sf);
  color: var(--mut);
}

.header-subline {
  font-size: 0.92rem;
}

.header-spacer {
  flex: 1;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: 0.28s ease;
}

.drawer-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: fixed;
  top: 0;
  left: -328px;
  width: 304px;
  height: 100%;
  background: var(--card);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow: var(--shd);
  z-index: 200;
  transition: left 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding: 28px 18px;
  border-radius: 0 28px 28px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer.open {
  left: 0;
}

.drawer-header {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--grenat);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.drawer-item {
  padding: 14px 16px;
  background: rgba(122,0,38,0.03);
  border-radius: 40px;
  border: 1px solid rgba(122,0,38,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: 0.15s ease;
}

.drawer-item:hover,
.drawer-item.active {
  background: var(--moutarde-pale);
  border-color: var(--grenat);
}

.drawer-item svg,
.drawer-header svg,
.card-title svg,
.small-title svg,
.footer .icn svg,
.mini-icon svg {
  color: var(--grenat);
}

.app-container {
  max-width: 1460px;
  margin: 0 auto;
  padding: 22px 24px;
}

.section {
  display: none;
  animation: fadeIn 0.35s ease;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--card);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 28px;
  padding: 24px;
  box-shadow: var(--shd);
  border: 1px solid rgba(255,255,255,0.55);
  margin-bottom: 20px;
}

.subcard {
  background: var(--card-2);
}

.hero-card {
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(248,227,183,0.45));
}

.card-title {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--grenat);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.small-title {
  font-size: 1.25rem;
}

.lead {
  font-size: 1.18rem;
  margin-bottom: 18px;
}

.grid-2, .grid-3 {
  display: grid;
  gap: 20px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-grid { margin-top: 14px; }

.mini-card {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(122,0,38,0.1);
}

.accent-card {
  background: linear-gradient(135deg, rgba(248,227,183,0.58), rgba(255,255,255,0.78));
}

.mini-card h3 {
  color: var(--grenat);
  margin: 8px 0;
  font-size: 1.25rem;
}

.mini-card p {
  font-family: var(--sf);
  font-size: 0.98rem;
  color: var(--mut);
}

.mini-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(122,0,38,0.08);
}

.logic-steps {
  display: grid;
  gap: 10px;
}

.logic-step-card {
  background: linear-gradient(135deg, rgba(230,182,86,0.18), rgba(122,0,38,0.05));
  border: 1px solid rgba(122,0,38,0.12);
  border-radius: 16px;
  padding: 12px 14px;
}

.logic-step-card strong { color: var(--grenat); }

.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}

.kpi {
  background: var(--moutarde-pale);
  color: var(--grenat);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
}

.math-block {
  background: var(--moutarde-tres-pale);
  padding: 16px;
  border-radius: 22px;
  border-left: 6px solid var(--moutarde);
  margin: 12px 0;
  font-size: 1.06rem;
  overflow-x: auto;
}

.stats-table,
.decision-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 22px;
  overflow: hidden;
}

.stats-table th,
.decision-table th {
  background: var(--g1);
  color: var(--grenat);
  padding: 11px 12px;
  font-family: var(--sf);
  font-size: 0.92rem;
  text-align: left;
}

.stats-table td,
.decision-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(122,0,38,0.06);
  font-family: var(--sf);
  font-size: 0.95rem;
}

.table-host {
  width: 100%;
  overflow-x: auto;
  margin-top: 12px;
}

.plot-container {
  width: 100%;
  min-height: 360px;
  background: white;
  border-radius: 26px;
  padding: 8px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.02);
}

.toolbar-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 4px;
}

.btn {
  background: var(--grenat);
  color: white;
  border: none;
  border-radius: 40px;
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.16s ease;
  box-shadow: var(--shd);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: scale(0.985);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--grenat);
  color: var(--grenat);
  box-shadow: none;
}

.btn-small {
  padding: 9px 15px;
  font-size: 0.95rem;
}

.ios-select,
.ios-input,
.ios-textarea {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(122,0,38,0.15);
  border-radius: 18px;
  padding: 14px 16px;
  width: 100%;
  font-size: 1rem;
  color: var(--ink);
  transition: 0.2s ease;
  margin-top: 6px;
  font-family: inherit;
}

.ios-select[multiple] {
  min-height: 152px;
}

.ios-select:focus,
.ios-input:focus,
.ios-textarea:focus {
  outline: none;
  border-color: var(--grenat);
  box-shadow: 0 0 0 3px rgba(122,0,38,0.1);
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0,1fr));
}

.form-group label {
  display: block;
  color: var(--grenat);
  font-weight: 700;
  margin-bottom: 4px;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  background: rgba(122,0,38,0.08);
  color: var(--grenat);
  border: 1px solid rgba(122,0,38,0.14);
  border-radius: 999px;
  padding: 7px 12px;
  font-family: var(--sf);
  font-size: 0.92rem;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.segment {
  border: 1px solid rgba(122,0,38,0.15);
  background: rgba(255,255,255,0.66);
  color: var(--grenat);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.18s ease;
  font-family: inherit;
}

.segment.active,
.segment:hover {
  background: var(--moutarde-pale);
  border-color: var(--grenat);
}

.special-controls {
  margin-top: 14px;
}

.hidden-block {
  display: none;
}

.toggles-inline {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  font-family: var(--sf);
}

.results-list {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding-right: 6px;
}

.result-item {
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(122,0,38,0.12);
  border-radius: 18px;
  padding: 12px 14px;
  cursor: pointer;
  transition: 0.15s ease;
}

.result-item:hover,
.result-item.active {
  background: var(--moutarde-pale);
  border-color: var(--grenat);
}

.result-item h4 {
  color: var(--grenat);
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.result-item p {
  color: var(--mut);
  font-family: var(--sf);
  font-size: 0.9rem;
}

.note {
  font-family: var(--sf);
  color: var(--mut);
  font-size: 0.95rem;
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 18px;
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 25;
}

/* ══════════════════════════════════════════════════════════════
   FOOTER iOS-STYLE (fixed)
══════════════════════════════════════════════════════════════ */
.ios-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px 24px;
  background: rgba(255, 251, 245, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(122, 0, 38, 0.08);
}

.footer-copyright {
  font-family: var(--sf);
  font-size: 0.88rem;
  color: var(--mut);
  letter-spacing: 0.01em;
}

.footer-links {
  display: flex;
  gap: 12px;
}

/* iOS-icon buttons */
.icn {
  width: 46px;
  height: 46px;
  border-radius: 14px;                    /* squircle shape */
  background: var(--grenat);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 5px 16px rgba(122, 0, 38, 0.30);
  transition: transform 0.2s, box-shadow 0.2s;
}

.icn:hover {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 10px 22px rgba(122, 0, 38, 0.36);
}

.icn svg { width: 20px; height: 20px; }

.success-chip,
.warning-chip,
.danger-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 12px;
  font-family: var(--sf);
  font-size: 0.92rem;
  font-weight: 700;
}

.success-chip { background: rgba(47,133,90,0.12); color: var(--vert); }
.warning-chip { background: rgba(230,182,86,0.24); color: #8c5300; }
.danger-chip { background: rgba(122,0,38,0.1); color: var(--grenat); }

code, pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (max-width: 980px) {
  .grid-2,
  .grid-3,
  .form-grid.two-col {
    grid-template-columns: 1fr;
  }

  .header-sub {
    display: none;
  }
}

@media (max-width: 720px) {
  .app-container { padding: 12px; }
  .card { padding: 18px; }
  .header-title { font-size: 1.45rem; }
  .header-subline { display: none; }
  .drawer { width: 280px; left: -304px; }
  .plot-container { min-height: 300px; }
  .footer { bottom: 12px; }
}


.advanced-note {
  font-family: var(--sf);
  color: var(--mut);
  font-size: 0.95rem;
}
