:root {
  color-scheme: light;
  --app-bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #dbe2ea;
  --border-strong: #c5d0dc;
  --text: #172033;
  --muted: #627085;
  --primary: #074bdf;
  --primary-pressed: #053aa9;
  --primary-soft: #e8f0ff;
  --cyan: #16d4e8;
  --danger: #c7362f;
  --danger-soft: #fff0ee;
  --shadow: 0 16px 40px rgba(23, 32, 51, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  background: var(--app-bg);
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

button:hover {
  border-color: var(--border-strong);
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.08);
}

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

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(22, 212, 232, 0.36);
  outline-offset: 2px;
}

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

.primary-action:hover {
  border-color: var(--primary-pressed);
  background: var(--primary-pressed);
}

.danger-action {
  border-color: #f0c6c2;
  background: var(--danger-soft);
  color: var(--danger);
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 24px)
    0
    calc(env(safe-area-inset-bottom, 0px) + 32px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.hero-copy,
.hero-stage,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 24px;
}

.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

.app-mark {
  position: relative;
  display: inline-flex;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--primary);
  overflow: hidden;
}

.app-mark::before,
.app-mark::after {
  position: absolute;
  content: "";
  border-radius: 999px;
  pointer-events: none;
}

.app-mark::before {
  width: 48px;
  height: 48px;
  top: -18px;
  left: -14px;
  background: rgba(22, 212, 232, 0.2);
}

.app-mark::after {
  width: 50px;
  height: 50px;
  right: -22px;
  bottom: -20px;
  background: rgba(3, 45, 159, 0.42);
}

.app-mark-pill {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 14px;
  border-radius: 999px;
  background: #ffffff;
}

.app-mark-dot {
  position: absolute;
  top: 3px;
  left: 6px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--cyan);
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

h1 {
  margin-top: 4px;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.lede {
  max-width: 64ch;
  margin-top: 16px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.hero-stage {
  position: relative;
  min-height: 220px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: var(--surface-muted);
}

.hero-stage::before {
  position: absolute;
  top: 34px;
  left: 50%;
  width: min(72%, 288px);
  height: 56px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow:
    inset 0 0 0 1px rgba(197, 208, 220, 0.6),
    0 18px 40px rgba(23, 32, 51, 0.12);
  content: "";
  transform: translateX(-50%);
}

.hero-stage::after {
  position: absolute;
  top: 48px;
  left: calc(50% - min(36%, 144px) + 24px);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--cyan);
  content: "";
}

.stage-copy,
.stage-actions {
  position: relative;
  z-index: 1;
}

.stage-copy span {
  display: block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.stage-copy strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.25;
}

.stage-copy p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.stage-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

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

.panel {
  padding: 18px;
}

.controls-panel,
.log-panel {
  grid-column: span 2;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-head p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

label > span {
  color: var(--text);
  font-weight: 600;
}

input[type="number"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
}

.toggle {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 44px;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
}

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

#log {
  min-height: 144px;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  color: var(--muted);
  line-height: 1.45;
}

#log:empty::before {
  display: block;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  content: "No events yet.";
}

#log li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

#log li:first-child {
  color: var(--text);
}

body[data-demo] {
  background: var(--surface-muted);
}

body[data-demo] .app-shell {
  width: min(460px, calc(100vw - 24px));
}

body[data-demo] .hero {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

body[data-demo] .hero-copy,
body[data-demo] main,
body[data-demo] .stage-actions,
body[data-demo] .stage-copy {
  display: none;
}

body[data-demo] .hero-stage {
  min-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 56px);
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 24px, 640px);
  }

  .hero,
  .grid,
  .controls-grid,
  .stage-actions {
    grid-template-columns: 1fr;
  }

  .controls-panel,
  .log-panel {
    grid-column: span 1;
  }

  .hero-copy,
  .panel {
    padding: 16px;
  }

  .hero-stage {
    min-height: 240px;
  }

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

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