:root {
  /* nmode.io scheme */
  --ivory: #fbfaf6;
  --paper: #ffffff;
  --ink: #202321;
  --muted: #6b716d;
  --line: #dedfd8;
  --poppy: #9a7488;
  --poppy-deep: #785767;
  --brand: #7357ff;
  --lilac: #deddf0;
  --lilac-deep: #67618e;
  --mint: #dcece4;
  --mint-deep: #3f6957;
  --silver: #edf0ef;
  --pearl: #f4f3ee;
  --stage-bg: #1a1c1b;
  --type-display: "Geist", "Helvetica Neue", sans-serif;
  --type-mono: "Geist Mono", ui-monospace, monospace;
  --type-body: "Geist", "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 30px 90px #2d342f21;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --cam-bar-h: calc(4.6rem + var(--safe-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 12% 0%, var(--lilac) 0%, transparent 55%),
    radial-gradient(800px 480px at 88% 100%, var(--mint) 0%, transparent 50%),
    linear-gradient(165deg, var(--ivory) 0%, var(--pearl) 55%, var(--silver) 100%);
  color: var(--ink);
  font-family: var(--type-body);
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

video,
#cast,
#preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  background: var(--stage-bg);
}

.tv.live video,
.tv.live #cast,
.tv.hold video,
.tv.hold #cast {
  object-fit: contain;
}

.cam video,
.cam #preview {
  transform: scaleX(-1);
}

.brand-block {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  max-width: min(20rem, 72vw);
  padding: 1rem 1.1rem 0;
  pointer-events: none;
}

.brand-block p,
.brand-block button {
  pointer-events: auto;
}

.wordmark,
h1 {
  margin: 0;
  font-family: var(--type-display);
  font-weight: 880;
  letter-spacing: -0.08em;
  line-height: 0.9;
  text-transform: lowercase;
}

.tv h1 {
  font-size: clamp(2.8rem, 12vmin, 8rem);
  font-weight: 880;
}

.cam h1 {
  font-size: clamp(1.7rem, 7vmin, 2.4rem);
  font-weight: 880;
}

.brand-block p,
.idle p {
  margin: 0.55rem 0 0;
  font-size: clamp(0.9rem, 2.8vmin, 1.05rem);
  line-height: 1.4;
  color: var(--muted);
}

.mode-label {
  position: absolute;
  top: calc(0.8rem + var(--safe-top));
  right: calc(0.9rem + var(--safe-right));
  z-index: 2;
  margin: 0;
  font-family: var(--type-mono);
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.idle {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.2rem;
  padding-bottom: calc(1.2rem + var(--safe-bottom));
}

.phone-url,
.trust-url {
  font-family: var(--type-mono);
  font-size: clamp(0.72rem, 2.2vmin, 0.88rem);
  letter-spacing: 0.02em;
  word-break: break-all;
  color: var(--ink);
}

.hold-badge {
  position: absolute;
  left: calc(1rem + var(--safe-left));
  bottom: calc(1rem + var(--safe-bottom));
  z-index: 3;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(251, 250, 246, 0.92);
  border: 1px solid rgba(222, 223, 216, 0.9);
  color: var(--muted);
  font-family: var(--type-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
}

.hold-badge[hidden] {
  display: none !important;
}

.rack {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--cam-bar-h);
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  padding: 0 0.65rem 0.45rem;
  max-height: 38vh;
}

.garment {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}

.garment img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  border-radius: 0.55rem;
  border: 1px solid rgba(222, 223, 216, 0.65);
}

.garment span {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--type-mono);
  font-size: clamp(0.65rem, 2vmin, 0.78rem);
  font-weight: 650;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.garment.active img {
  outline: 2px solid var(--poppy);
  outline-offset: 2px;
}

.cam-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem calc(0.75rem + var(--safe-bottom));
  background: rgba(32, 35, 33, 0.92);
  box-shadow: 0 -12px 40px rgba(45, 52, 47, 0.18);
}

.cam-bar button {
  border: 1px solid rgba(222, 223, 216, 0.35);
  background: rgba(251, 250, 246, 0.94);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  font: inherit;
  font-weight: 650;
  min-height: 2.75rem;
}

#enable-cam {
  display: block;
  width: 100%;
  min-height: 3.25rem;
  border: none;
  border-radius: 999px;
  background: var(--ivory);
  color: var(--ink);
  font: inherit;
  font-size: clamp(1rem, 3.5vmin, 1.12rem);
  font-weight: 720;
}

#enable-cam[disabled] {
  opacity: 0.65;
}

#enable-cam[hidden],
#sleep[hidden] {
  display: none !important;
}

.error {
  color: var(--poppy-deep);
}

.cam .error {
  color: #f0d6e2;
}

.tv.live .idle,
.tv.hold .idle {
  display: none;
}

@media (orientation: landscape) {
  .cam .brand-block {
    max-width: min(16rem, 42vw);
    padding-top: 0.65rem;
  }

  .cam .rack {
    left: auto;
    right: calc(0.5rem + var(--safe-right));
    width: min(42vw, 18rem);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: calc(100% - var(--cam-bar-h) - 0.5rem);
    bottom: var(--cam-bar-h);
    align-content: end;
  }

  .cam .garment img {
    aspect-ratio: 3 / 4;
  }

  .cam video,
  .cam #preview {
    object-fit: contain;
  }

  .tv .idle {
    justify-content: center;
    align-items: flex-start;
    max-width: min(36rem, 72vw);
  }

  .tv h1 {
    font-size: clamp(2.4rem, 10vmin, 5.5rem);
  }
}

@media (max-height: 520px) {
  .cam .brand-block {
    max-width: 14rem;
  }

  .cam h1 {
    font-size: 1.45rem;
  }

  .cam .rack {
    gap: 0.3rem;
    padding-bottom: 0.25rem;
  }

  .cam .garment span {
    display: none;
  }

  :root {
    --cam-bar-h: calc(3.8rem + var(--safe-bottom));
  }
}
