:root {
  --surface: #ffffff;
  --page: #f3f3f3;
  --ink: #212121;
  --muted: #666666;
  --line: #c4c4c4;
  --line-strong: #9e9e9e;
  --accent: #0d47a1;
  --focus: #1976d2;
  --error: #c62828;
  --success: #2e7d32;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.demo-page {
  min-height: 100vh;
  padding: 32px 16px;
}

.demo-shell {
  max-width: 1180px;
  margin: 0 auto;
}

.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 400;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 18px;
  margin-bottom: 22px;
}

.demo-copy,
.results-copy,
.status-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.mono {
  font-family: "Courier New", Courier, monospace;
}

.mode-switcher {
  display: flex;
  gap: 10px;
}

.mode-pill {
  border: 1px solid #d7d7d7;
  background: #fafafa;
  color: #5f5f5f;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
}

.mode-pill.is-active {
  border-color: #d1d1d1;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.demo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.payment-dialog,
.results-card {
  background: var(--surface);
  border: 1px solid #e0e0e0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.payment-dialog {
  max-width: 560px;
  min-height: 430px;
  padding: 22px 14px 10px;
}

.results-card {
  padding: 18px;
}

.results-panel {
  display: grid;
  gap: 16px;
}

.saved-options {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.debug-panel summary {
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  font-weight: 700;
}

.debug-panel summary::-webkit-details-marker {
  display: none;
}

.debug-panel summary::after {
  content: "Show less";
  float: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.debug-panel:not([open]) summary::after {
  content: "Show more";
}

.debug-log {
  margin-top: 12px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid #ebebeb;
  background: #fafafa;
}

.debug-log-entry {
  padding: 10px 12px;
  border-top: 1px solid #ebebeb;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.debug-log-entry:first-child {
  border-top: 0;
}

.saved-option {
  border: 1px solid #ebebeb;
  border-left: 3px solid #9e9e9e;
  padding: 12px;
  background: #fcfcfc;
}

.saved-option strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.saved-option span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field > span {
  display: block;
  color: #757575;
  font-size: 15px;
  margin-bottom: 8px;
}

.field input,
.field select {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0 0 6px;
  height: 32px;
  background: transparent;
  color: var(--ink);
  outline: 0;
}

.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #757575 50%), linear-gradient(135deg, #757575 50%, transparent 50%);
  background-position: calc(100% - 12px) 14px, calc(100% - 8px) 14px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.field input:focus,
.field select:focus {
  border-bottom-color: var(--focus);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  color: #5b5b5b;
  font-size: 14px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 30px;
}

.text-button {
  border: 0;
  background: transparent;
  color: #666666;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 8px 0;
  cursor: pointer;
}

.text-button.is-disabled,
.text-button:disabled {
  color: #c8c8c8;
  cursor: not-allowed;
}

.status-text {
  min-height: 22px;
}

.status-text.is-error {
  color: var(--error);
}

.status-text.is-success {
  color: var(--success);
}

.secure-frame {
  display: block;
  width: 100%;
  height: 42px;
  border: 0;
  background: transparent;
}

.secure-body {
  background: transparent;
}

.secure-shell {
  width: 100%;
}

.secure-field-root,
.secure-mock-input {
  width: 100%;
  height: 32px;
  border-bottom: 1px solid var(--line);
}

.secure-message {
  margin: 6px 0 0;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.secure-message.is-error {
  color: var(--error);
}

.secure-mock-input {
  border-top: 0;
  border-left: 0;
  border-right: 0;
  padding: 0 0 6px;
  background: transparent;
  outline: 0;
}

.secure-mock-input:focus {
  border-bottom-color: var(--focus);
}

.is-hidden {
  display: none;
}

@media (max-width: 920px) {
  .demo-header,
  .demo-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .mode-switcher {
    justify-content: start;
  }
}

@media (max-width: 640px) {
  .payment-dialog {
    min-height: auto;
    padding: 18px 12px 10px;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .dialog-actions {
    gap: 14px;
  }
}
