.mesat-preview,
.mesat-dialog {
  --mesat-ink: #172b46;
  --mesat-muted: var(--muted, #455c76);
  --mesat-surface: var(--surface, #fff);
  --mesat-stroke: var(--line, #a8bad1);
  --mesat-soft: var(--subtle, #eef4fb);
  --mesat-primary: var(--blue, #293f77);
  --mesat-focus: var(--focus, #4164a2);
  color: var(--mesat-ink);
}

.mesat-preview {
  display: grid;
  gap: .6rem;
  min-inline-size: 0;
  padding: .85rem;
  border: 1px solid var(--mesat-stroke);
  border-radius: .8rem;
  background: var(--mesat-surface);
}

.mesat-preview-heading,
.mesat-dialog-heading {
  margin: 0;
  font-size: clamp(1.16rem, 3.6vw, 1.48rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.mesat-preview-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: .65rem;
}

.mesat-preview-detail { display: grid; justify-items: start; gap: .25rem; min-inline-size: 0; }
.mesat-preview-step { margin: 0; font-weight: 650; overflow-wrap: anywhere; }

.mesat-dialog {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  inline-size: min(42rem, calc(100% - 1rem));
  max-inline-size: none;
  max-block-size: calc(100dvh - 1rem);
  margin: auto;
  padding: 0;
  border: 1px solid var(--mesat-stroke);
  border-radius: .9rem;
  background: var(--mesat-surface);
  overflow: hidden;
}

.mesat-dialog[open] { display: flex; flex-direction: column; }
.mesat-dialog::backdrop { background: #172b4685; }
body:has(> .mesat-dialog[open]) { overflow: hidden; }

.mesat-header,
.mesat-footer {
  flex: 0 0 auto;
  min-inline-size: 0;
  padding: .6rem clamp(.55rem, 3vw, 1.25rem);
}

.mesat-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  border-block-end: 1px solid var(--mesat-stroke);
}

.mesat-progress {
  flex: 0 0 auto;
  margin: 0;
  padding: .45rem clamp(.55rem, 3vw, 1.25rem);
  color: var(--mesat-muted);
  background: var(--mesat-soft);
  font-weight: 700;
}

.mesat-content {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: .65rem;
  min-block-size: 0;
  min-inline-size: 0;
  padding: .75rem clamp(.55rem, 3vw, 1.25rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.mesat-footer {
  display: grid;
  gap: .45rem;
  border-block-start: 1px solid var(--mesat-stroke);
}

.mesat-actions,
.mesat-needs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .4rem;
}

.mesat-actions .mesat-button:only-of-type,
.mesat-actions > [hidden] + .mesat-button { grid-column: 1 / -1; }
.mesat-dialog [hidden] { display: none !important; }

.mesat-preview .mesat-button,
.mesat-dialog .mesat-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-block-size: 44px;
  min-inline-size: 44px;
  max-inline-size: 100%;
  margin: 0;
  padding: .48rem .65rem;
  border: 1px solid var(--mesat-stroke);
  border-radius: .55rem;
  color: var(--mesat-ink);
  background: var(--mesat-surface);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.mesat-dialog .mesat-primary { color: #fff; border-color: var(--mesat-primary); background: var(--mesat-primary); }
.mesat-dialog .mesat-button:disabled { opacity: .65; cursor: default; }
.mesat-dialog .mesat-needs .mesat-button { background: var(--mesat-soft); }

.mesat-preview .mesat-button {
  inline-size: 100%;
  justify-content: flex-start;
  color: var(--mesat-primary);
  background: var(--mesat-soft);
  text-align: start;
}

:is(.mesat-preview, .mesat-dialog) :is(button, [tabindex]):focus-visible {
  outline: 3px solid var(--mesat-focus);
  outline-offset: 2px;
}

.mesat-step,
.mesat-copy,
.mesat-inline-message {
  box-sizing: border-box;
  display: grid;
  gap: .5rem;
  inline-size: 100%;
  min-inline-size: 0;
  padding: .65rem .75rem;
  border: 1px solid var(--mesat-stroke);
  border-radius: .65rem;
  overflow-wrap: anywhere;
}

.mesat-now { border-inline-start: .28rem solid var(--mesat-primary); background: var(--mesat-soft); }
.mesat-section-title { margin: 0; font-size: 1rem; }

.mesat-step-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: .65rem;
  min-inline-size: 0;
}

.mesat-facts { display: grid; justify-items: start; gap: .35rem; min-inline-size: 0; }
.mesat-step-name { margin: 0; font-size: clamp(1.06rem, 4.3vw, 1.38rem); line-height: 1.2; }
.mesat-location, .mesat-notes, .mesat-old p { margin: 0; white-space: pre-wrap; }

.mesat-icon {
  display: inline-grid;
  place-items: center;
  inline-size: 3rem;
  block-size: 3rem;
  border-radius: .5rem;
  background: var(--mesat-surface);
  font-size: 1.65rem;
  line-height: 1;
}

.mesat-photo {
  display: block;
  inline-size: 3.5rem;
  block-size: 3.5rem;
  max-inline-size: 100%;
  border-radius: .5rem;
  object-fit: cover;
}

.mesat-now .mesat-photo { inline-size: min(10rem, 28vw); block-size: auto; max-block-size: 31dvh; object-fit: contain; }

.mesat-old {
  display: grid;
  gap: .25rem;
  padding: .5rem .6rem;
  border: 1px dashed var(--mesat-stroke);
  border-radius: .4rem;
  background: var(--mesat-surface);
}

.mesat-flag {
  justify-self: start;
  margin: 0;
  padding: .28rem .48rem;
  border: 1px solid var(--mesat-stroke);
  border-radius: .38rem;
  color: var(--mesat-ink);
  background: var(--mesat-surface);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mesat-empty { margin: 0; font-size: 1.12rem; font-weight: 650; }
.mesat-muted, .mesat-status { margin: 0; color: var(--mesat-muted); overflow-wrap: anywhere; }
.mesat-copy-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.mesat-inline-message p { margin: 0; font-size: clamp(1.4rem, 6vw, 2.5rem); font-weight: 750; }

.mesat-status:empty {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-height: 36rem) and (min-width: 37rem) {
  .mesat-footer { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mesat-status { grid-column: 1 / -1; }
}
