:root {
  --ink: #17140f;
  --muted: #6b6157;
  --faint: #a89b8c;
  --line: #e8e0d5;
  --paper: #ece9e3;
  --gold: #e8a22b;
  --green: #0b6b3a;
  --clay: #d8452b;
  --surface: #fbfaf7;
  --rail: #f3efe6;
  --font: "Hanken Grotesk", system-ui, sans-serif;
  --display: "Space Grotesk", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
}

.shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 22px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.rail-brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.rail-brand span {
  color: var(--gold);
}

.rail-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

.rail-group h2 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}

.rail-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.rail-list button {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.3;
}

.rail-list button:hover {
  background: rgba(255, 255, 255, 0.7);
}

.rail-list button.active {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 1px 0 rgba(23, 20, 15, 0.04);
  font-weight: 600;
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.rail-foot a {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
}

.rail-foot a:hover {
  color: var(--ink);
}

.stage {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 90%, #fff);
  position: sticky;
  top: 0;
  z-index: 5;
}

.stage-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stage-title strong {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#flow-pill {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.stage-actions {
  display: flex;
  gap: 8px;
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.ghost:disabled {
  opacity: 0.4;
  cursor: default;
}

.ghost:not(:disabled):hover {
  border-color: var(--ink);
}

.phone-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 40px;
  gap: 16px;
}

.phone {
  width: min(390px, calc(100vw - 32px));
  height: min(844px, calc(100vh - 140px));
  aspect-ratio: 390 / 844;
  max-height: 844px;
  border-radius: 48px;
  background: #0e0d0a;
  padding: 11px;
  box-shadow: 0 40px 80px -34px rgba(23, 20, 15, 0.55);
  position: relative;
}

/* Injected design frame often has its own outer shell — strip double bezel if nested */
.phone > .frame-host {
  width: 100%;
  height: 100%;
  border-radius: 38px;
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.phone > .frame-host > [data-phone-root] {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  border-radius: 38px !important;
  box-shadow: none !important;
  padding: 0 !important;
  background: transparent !important;
}

.phone > .frame-host > [data-phone-root] > .ns,
.phone > .frame-host > [data-phone-root] > div {
  height: 100%;
}

.phone-loading {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--surface);
  border-radius: 38px;
}

.hint {
  margin: 0;
  max-width: 360px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Clickable affordances inside mock screens */
.frame-host [data-mock-click],
.frame-host button,
.frame-host [role="button"] {
  cursor: pointer !important;
}

.frame-host [data-mock-click]:hover {
  filter: brightness(0.98);
  outline: 2px solid color-mix(in srgb, var(--gold) 55%, transparent);
  outline-offset: 1px;
}

.frame-host [data-mock-active] {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  max-width: min(90vw, 360px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .rail-list {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .rail-list button {
    font-size: 0.78rem;
    padding: 7px 9px;
  }

  .phone {
    height: min(720px, calc(100vh - 220px));
  }
}
