:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-muted: #faf9f6;
  --ink: #0c0a09;
  --ink-strong: #000000;
  --muted: #57534e;
  --muted-2: #8a837c;
  --line: #e7e4dd;
  --line-strong: #d1cdc4;
  --accent: #005f73;
  --accent-ink: #004a5a;
  --accent-soft: #e2eff2;
  --success-bg: #ecfdf5;
  --success-ink: #065f46;
  --success-line: #a7f3d0;
  --warning-bg: #fffbeb;
  --warning-ink: #854d0e;
  --warning-line: #fde68a;
  --error-bg: #fef2f2;
  --error-ink: #991b1b;
  --error-line: #fecaca;
  --info-bg: #f5f5f4;
  --info-ink: #44403c;
  --info-line: #e7e5e4;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(12, 10, 9, 0.05);
  --shadow-md: 0 14px 40px -12px rgba(12, 10, 9, 0.12);
  --tap: 48px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
}

h1,
h2,
h3,
h4,
p,
ol,
ul {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ----- Page (mobile-first) ----- */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 14px 56px;
}

.site-brand {
  display: flex;
  justify-content: center;
  margin: 0 auto 20px;
  padding: 4px;
  text-decoration: none;
}

.site-brand__logo {
  display: block;
  height: 64px;
  width: auto;
  max-width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* ----- Card ----- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ----- Steps ----- */

.steps {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0 4px;
}

.steps__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.steps__marker {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--muted-2);
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.steps__divider {
  flex: 1;
  height: 1px;
  background: var(--line);
  transition: background-color 0.2s ease;
}

/* active step */
.steps[data-current="1"] .steps__item[data-step="1"],
.steps[data-current="2"] .steps__item[data-step="2"] {
  color: var(--ink);
}

.steps[data-current="1"] .steps__item[data-step="1"] .steps__marker,
.steps[data-current="2"] .steps__item[data-step="2"] .steps__marker {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

/* completed step 1 when on step 2 */
.steps[data-current="2"] .steps__item[data-step="1"] {
  color: var(--ink);
}

.steps[data-current="2"] .steps__item[data-step="1"] .steps__marker {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
  font-size: 0;
  position: relative;
}

.steps[data-current="2"] .steps__item[data-step="1"] .steps__marker::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--surface);
  border-bottom: 2px solid var(--surface);
  transform: translateY(-1px) rotate(-45deg);
}

.steps[data-current="2"] .steps__divider {
  background: var(--accent);
}

/* ----- Response banner ----- */

.response {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 14px;
}

.response[hidden] {
  display: none;
}

.response strong {
  font-weight: 600;
}

.response--idle,
.response--loading {
  background: var(--info-bg);
  border-color: var(--info-line);
  color: var(--info-ink);
}

.response--success {
  background: var(--success-bg);
  border-color: var(--success-line);
  color: var(--success-ink);
}

.response--warning {
  background: var(--warning-bg);
  border-color: var(--warning-line);
  color: var(--warning-ink);
}

.response--error {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-ink);
}

/* ----- Step panel ----- */

.step-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.step-panel[hidden] {
  display: none;
}

.step-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.step-panel__head h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.step-panel__head .button {
  flex-shrink: 0;
}

.header-tools {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.environment-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.environment-picker select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 36px;
  min-width: 82px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2357534e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

/* ----- Grid & fields (single column by default) ----- */

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

.grid--two {
  grid-template-columns: 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field__label em {
  color: var(--muted-2);
  font-style: normal;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.field__required {
  color: var(--accent);
  font-weight: 600;
}

.field__error {
  font-size: 13px;
  color: var(--error-ink);
  display: none;
  align-items: center;
  gap: 6px;
}

.field__error::before {
  content: "!";
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--error-ink);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.field[data-invalid="true"] .field__error {
  display: inline-flex;
}

.field__help {
  min-height: 16px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.address-map {
  display: grid;
  gap: 8px;
}

.address-map[hidden] {
  display: none;
}

.address-map__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.address-map__canvas {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-muted);
  overflow: hidden;
}

.field__input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.field__input::placeholder {
  color: var(--muted-2);
}

.field__input:hover:not(:focus) {
  border-color: var(--muted-2);
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 95, 115, 0.15);
}

.field[data-invalid="true"] .field__input {
  border-color: var(--error-ink);
}

.field[data-invalid="true"] .field__input:focus {
  box-shadow: 0 0 0 3px rgba(153, 27, 27, 0.12);
}

.field__input--multiline {
  min-height: 112px;
  resize: vertical;
  padding: 12px 14px;
  line-height: 1.5;
}

select.field__input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%2357534e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.pac-container {
  z-index: 10000;
}

/* ----- Actions (mobile-first: stacked, primary at bottom) ----- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.actions .button {
  width: 100%;
}

/* ----- Buttons ----- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease,
    transform 0.08s ease, box-shadow 0.12s ease;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button__icon {
  font-size: 15px;
  line-height: 1;
}

.button--primary {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

.button--primary:hover:not(:disabled) {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  box-shadow: 0 6px 16px -8px rgba(0, 95, 115, 0.5);
}

.button--ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.button--ghost:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: var(--muted-2);
}

.button--sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* ----- API log ----- */

.api-log {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: 720px;
  overflow: hidden;
}

.api-log__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.api-log__head h2 {
  font-size: 16px;
  font-weight: 600;
}

.api-log__head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.api-log__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  overflow: auto;
  padding: 12px;
}

.api-log__empty {
  padding: 16px 4px;
  color: var(--muted-2);
  font-size: 13px;
}

.api-log-entry {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-muted);
  overflow: hidden;
}

.api-log-entry__summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
}

.api-log-entry__summary::-webkit-details-marker {
  display: none;
}

.api-log-entry__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.api-log-entry__endpoint {
  font-size: 13px;
  font-weight: 600;
}

.api-log-entry__meta {
  color: var(--muted);
  font-size: 12px;
}

.api-log-entry__status {
  align-self: start;
  border: 1px solid var(--info-line);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface);
  color: var(--info-ink);
  font-size: 12px;
  font-weight: 600;
}

.api-log-entry[data-state="success"] .api-log-entry__status {
  border-color: var(--success-line);
  background: var(--success-bg);
  color: var(--success-ink);
}

.api-log-entry[data-state="error"] .api-log-entry__status {
  border-color: var(--error-line);
  background: var(--error-bg);
  color: var(--error-ink);
}

.api-log-entry__body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.api-log-entry__block {
  display: grid;
  gap: 4px;
}

.api-log-entry__block span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.api-log-entry__block pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 10px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =====================================================================
   Progressive enhancement for larger screens
   ===================================================================== */

@media (min-width: 560px) {
  .page {
    padding: 32px 20px 64px;
  }

  .card {
    padding: 24px;
    gap: 22px;
  }

  .site-brand {
    margin-bottom: 24px;
  }

  .site-brand__logo {
    height: 80px;
  }

  .actions {
    flex-direction: row;
    gap: 12px;
  }

  .actions .button {
    width: auto;
  }

  .actions--end {
    justify-content: flex-end;
  }

  .actions--split {
    justify-content: space-between;
  }
}

@media (min-width: 720px) {
  .page {
    padding: 40px 24px 80px;
  }

  .card {
    padding: 32px;
    gap: 24px;
  }

  .grid--two {
    grid-template-columns: 1fr 1fr;
  }

  .step-panel__head h2 {
    font-size: 19px;
  }
}

@media (min-width: 1040px) {
  .workspace {
    grid-template-columns: minmax(0, 760px) minmax(320px, 1fr);
    gap: 18px;
  }

  .api-log {
    position: sticky;
    top: 24px;
    max-height: calc(100dvh - 48px);
  }
}

@media (max-width: 400px) {
  .steps[data-current="1"] .steps__item[data-step="2"] .steps__text,
  .steps[data-current="2"] .steps__item[data-step="1"] .steps__text {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
