/* ─────────────────────────────────────────────────────────────
   Demo shell — full-bleed by default, Fold8 device frame on demand.
   ───────────────────────────────────────────────────────────── */

.sim {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background:
    radial-gradient(120% 90% at 50% -10%, #6f8177 0%, #5b6c62 38%, #46544c 100%);
  overflow: hidden;
}

.sim::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.3;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.32'/></svg>");
  mix-blend-mode: overlay;
}

/* ── stage ───────────────────────────────────────────────────── */
.stage {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  padding: 10px;
}

.rig {
  --sw: 900px;
  --sh: 812px;
  --sc: 0.8;
  position: relative;
  width: calc((var(--sw) + 26px) * var(--sc));
  height: calc((var(--sh) + 30px) * var(--sc));
  transition: width 0.55s var(--ease), height 0.55s var(--ease);
}

.rig-shell {
  position: absolute;
  left: 0;
  top: 0;
  width: max-content;
  transform: scale(var(--sc));
  transform-origin: 0 0;
  transition: transform 0.55s var(--ease);
}

.rig-chassis {
  position: relative;
  padding: 13px;
  border-radius: 44px;
  background: linear-gradient(160deg, #212426 0%, #101112 42%, #191b1d 100%);
  box-shadow:
    0 0 0 1px #34383b,
    0 0 0 2px #0b0c0d,
    0 26px 60px rgba(12, 18, 15, 0.55),
    0 6px 16px rgba(12, 18, 15, 0.4);
  transition: padding 0.5s var(--ease), border-radius 0.5s var(--ease);
}

.rig-glass {
  position: relative;
  border-radius: 32px;
  overflow: hidden;
  background: #0b0b0b;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 0 24px rgba(0, 0, 0, 0.6);
}

.host {
  width: var(--sw);
  height: var(--sh);
  border-radius: 32px;
  transition: width 0.5s var(--ease), height 0.5s var(--ease), border-radius 0.5s var(--ease);
}

.rig-cam {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #050505;
  box-shadow: inset 0 0 1px rgba(255, 255, 255, 0.4);
  z-index: 6;
  opacity: 0.85;
}

.rig-seam {
  position: absolute;
  left: 13px;
  right: 13px;
  top: 50%;
  height: 12px;
  transform: translateY(-50%);
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s var(--ease);
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.09) 0%,
    rgba(0, 0, 0, 0.42) 40%,
    rgba(0, 0, 0, 0.5) 55%,
    rgba(255, 255, 255, 0.06) 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.rig[data-mode="laptop"] .rig-seam { opacity: 1; }
.rig-seam i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.25);
}

.rig-shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -34px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(10, 16, 13, 0.5) 0%, transparent 70%);
  filter: blur(10px);
  z-index: -1;
  transition: left 0.5s var(--ease), right 0.5s var(--ease);
}

/* ══════════════════════════════════════════════════════════════
   FULL-BLEED VIEW — the app is the whole window
   ══════════════════════════════════════════════════════════════ */
.sim[data-view="fill"] .stage { padding: 0; display: block; }

.sim[data-view="fill"] .rig {
  width: 100% !important;
  height: 100% !important;
}

.sim[data-view="fill"] .rig-shell {
  inset: 0;
  width: auto;
  transform: none;
}

.sim[data-view="fill"] .rig-chassis {
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.sim[data-view="fill"] .rig-glass {
  height: 100%;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.sim[data-view="fill"] .host {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
  transition: none;
}

.sim[data-view="fill"] .rig-seam,
.sim[data-view="fill"] .rig-cam,
.sim[data-view="fill"] .rig-shadow { display: none; }

/* ── bottom bar ──────────────────────────────────────────────── */
.sim-bar {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 54px;
  padding: 0 16px;
  background: rgba(23, 31, 27, 0.94);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
}

.bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.bar-left .cat-mark { width: 24px; height: 24px; flex: 0 0 auto; }

.bar-brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bar-brand b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  line-height: 1;
  color: #f4f0ec;
  white-space: nowrap;
}
.bar-brand span {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(244, 240, 236, 0.42);
  white-space: nowrap;
}

.bar-mid { display: flex; align-items: center; gap: 14px; }

.posture-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(12, 24, 19, 0.5);
  box-shadow: inset 0 0 0 1px rgba(244, 240, 236, 0.12);
}
.posture-switch button {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(244, 240, 236, 0.55);
  padding: 5px 12px;
  border-radius: 999px;
  transition: background 0.25s, color 0.25s;
}
.posture-switch button:hover { color: #fff; }
.posture-switch button.is-on {
  background: #f1ece7;
  color: #23211d;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.fold-range { display: flex; align-items: center; gap: 8px; }
.fold-range-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 240, 236, 0.4);
  white-space: nowrap;
}
.fold-range input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 118px;
  height: 16px;
  background: transparent;
  cursor: ew-resize;
}
.fold-range input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(244,240,236,0.45), rgba(244,240,236,0.14));
}
.fold-range input[type="range"]::-moz-range-track {
  height: 2px; border-radius: 2px; background: rgba(244, 240, 236, 0.28);
}
.fold-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #f1ece7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.fold-range input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px; border: 0; border-radius: 50%;
  background: #f1ece7; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.fold-range output {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(244, 240, 236, 0.75);
  width: 34px;
  font-variant-numeric: tabular-nums;
}

.sim-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(244, 240, 236, 0.55);
  text-transform: uppercase;
  white-space: nowrap;
}
.sim-state i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #b6cfa9;
  box-shadow: 0 0 0 3px rgba(182, 207, 169, 0.16);
  transition: background 0.4s;
}
.sim-state.is-folded i { background: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 75, 0.18); }
.sim-state.is-closed i { background: #cf8a72; box-shadow: 0 0 0 3px rgba(207, 138, 114, 0.18); }

.bar-right { display: flex; align-items: center; gap: 7px; }

.ghost {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: rgba(244, 240, 236, 0.6);
  border: 1px solid rgba(244, 240, 236, 0.2);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.ghost:hover { color: #f4f0ec; border-color: rgba(244, 240, 236, 0.5); }
.ghost[aria-pressed="true"] { color: #f4f0ec; border-color: rgba(244, 240, 236, 0.5); }

/* ── responsive bar ──────────────────────────────────────────── */
@media (max-width: 1150px) {
  .sim-state { display: none; }
  .fold-range-label { display: none; }
}

@media (max-width: 900px) {
  .sim-bar { gap: 10px; padding: 0 10px; height: 50px; }
  .bar-brand span { display: none; }
  .bar-brand b { font-size: 14px; }
  .bar-left .cat-mark { width: 20px; height: 20px; }
  .fold-range input[type="range"] { width: 82px; }
  .ghost { font-size: 8.5px; padding: 4px 8px; letter-spacing: 0.04em; }
  .posture-switch button { font-size: 9px; padding: 4px 9px; }
}

@media (max-width: 700px) {
  .bar-left { display: none; }
  .bar-mid { gap: 8px; }
  .bar-right { gap: 5px; }
}

/* ── real device: no chrome, full bleed ──────────────────────── */
body[data-real="1"] .sim-bar { display: none; }
body[data-real="1"] .sim { grid-template-rows: 1fr; }
body[data-real="1"] .stage { padding: 0; width: 100vw; height: 100dvh; display: block; }
body[data-real="1"] .rig { width: 100vw !important; height: 100dvh !important; }
body[data-real="1"] .rig-shell { inset: 0; width: auto; transform: none; }
body[data-real="1"] .rig-chassis { width: 100%; height: 100%; padding: 0; border-radius: 0; background: transparent; box-shadow: none; }
body[data-real="1"] .rig-glass,
body[data-real="1"] .host { height: 100%; border-radius: 0; }
body[data-real="1"] .rig-seam,
body[data-real="1"] .rig-cam,
body[data-real="1"] .rig-shadow { display: none; }
body[data-real="1"] .host { width: 100vw; height: 100dvh; }

/* ── true fullscreen: bar becomes an auto-hiding overlay ─────── */
body.is-fs .sim { grid-template-rows: 1fr; }

body.is-fs .sim-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateY(100%);
  transition: transform 0.3s var(--ease);
  background: rgba(18, 24, 21, 0.88);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
}

body.is-fs .sim-bar.is-shown { transform: none; }

/* ── auto-hide bar: app fills the viewport, controls float ───── */
body[data-autohide="1"] .sim { grid-template-rows: 1fr; }

body[data-autohide="1"] .sim-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateY(100%);
  transition: transform 0.32s var(--ease);
  background: rgba(18, 24, 21, 0.9);
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.22);
}

body[data-autohide="1"] .sim-bar.is-shown { transform: none; }

.bar-handle {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 14px;
  z-index: 9;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 7px 11px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: rgba(244, 240, 236, 0.65);
  background: rgba(23, 31, 27, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 6px 18px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
  transition: opacity 0.25s, color 0.2s;
}
.bar-handle i {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  opacity: 0.7;
}
body[data-autohide="1"] .bar-handle { display: inline-flex; }
body[data-autohide="1"] .sim-bar.is-shown ~ .bar-handle,
body[data-autohide="1"] .bar-handle:hover { opacity: 1; }
body[data-autohide="1"] .sim-bar.is-shown + .bar-handle { opacity: 0; pointer-events: none; }
body[data-autohide="1"] .bar-handle { opacity: 0.55; }
