:root {
  --bg: #0e0f0d;
  --panel: #171915;
  --line: #2a2d27;
  --text: #ecefe8;
  --muted: #9aa094;
  --accent: #a5fe7d;
  --hint: rgba(37, 132, 255, .28);
  --hint-line: rgba(37, 132, 255, .9);
  --screen-w: 402px;
  --screen-h: 874px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Side panel ---------- */
#panel {
  width: 330px; flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  height: 100%;
  overflow-y: auto;
}
#panel header { padding: 20px 20px 14px; }
.brand { font-size: 26px; font-weight: 700; letter-spacing: -.5px; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
.intro { margin: 6px 0 10px; color: var(--muted); font-size: 13px; }
.how { margin: 0 0 14px; padding-left: 18px; font-size: 12.5px; color: var(--text); }
.how li { margin: 2px 0; }
.how em { font-style: normal; color: var(--muted); }
.primary {
  width: 100%; padding: 10px 14px; border: 0; border-radius: 12px;
  background: var(--accent); color: #0e0f0d; font-weight: 700; font-size: 14px;
}
.primary:hover { filter: brightness(1.06); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 14px; border-bottom: 1px solid var(--line); }
.controls button {
  background: #22251f; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px;
}
.controls button:hover { border-color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); width: 100%; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

#flows { flex: 1 0 auto; padding: 6px 12px 20px; }
#flows h2.role {
  margin: 18px 8px 4px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 15px; font-weight: 700; color: var(--accent);
}
#flows h2.role:first-child { border-top: 0; padding-top: 4px; margin-top: 8px; }
#flows h2.role small { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 4px; }
#flows h3 { margin: 12px 8px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
#flows button.flow {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-left: 2px solid transparent; border-radius: 8px;
  padding: 7px 10px; color: var(--text);
}
#flows button.flow { scroll-margin: 12px 0 120px; }
#flows button.flow .t { display: block; font-size: 13.5px; font-weight: 500; }
#flows button.flow .d { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
#flows button.flow:hover { background: #22251f; }
#flows button.flow.on { background: rgba(165, 254, 125, .1); border-left-color: var(--accent); }
#flows button.flow.on .t { color: var(--accent); }

#panel footer { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 12px 20px 16px; font-size: 12px; color: var(--muted); }
.here { margin: 0 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
#where .sec { display: block; font-size: 12px; }
#where strong { display: block; color: var(--text); font-size: 14px; }
#where .scr { display: block; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Device ---------- */
#stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; }
#menu { display: none; }

#device {
  --s: 1;
  width: calc((var(--screen-w) + 28px) * var(--s));
  height: calc((var(--screen-h) + 28px) * var(--s));
  padding: calc(14px * var(--s));
  background: #050505;
  border-radius: calc(62px * var(--s));
  box-shadow: 0 0 0 calc(2px * var(--s)) #3a3d37, 0 30px 80px rgba(0, 0, 0, .55);
}
#viewport {
  position: relative;
  width: var(--screen-w); height: var(--screen-h);
  transform: scale(var(--s)); transform-origin: 0 0;
  border-radius: 48px;
  overflow: hidden;
  background: #fff;
}

.screen {
  position: absolute; inset: 0;
  overflow-x: hidden; overflow-y: auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
  background: #fff;
}
.screen::-webkit-scrollbar { display: none; }
.screen .content { position: relative; width: var(--screen-w); }
.screen img.shot { position: absolute; top: 0; display: block; user-select: none; -webkit-user-drag: none; pointer-events: none; }

.screen.enter { animation: enter .22s ease-out both; }
.screen.enter.back { animation-name: enter-back; }
@keyframes enter { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes enter-back { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.screen.same { animation: fade .14s ease-out both; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }

.hs {
  position: absolute; display: block; padding: 0; margin: 0;
  background: transparent; border: 0; border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}
.hints .hs:not(.fixed), .flash .hs:not(.fixed) { background: var(--hint); box-shadow: inset 0 0 0 1.5px var(--hint-line); }
.flash .hs:not(.fixed) { animation: flash .6s ease-out both; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.hs:active { background: rgba(37, 132, 255, .18); }

.fixed { position: absolute; z-index: 2; background-repeat: no-repeat; border: 0; padding: 0; border-radius: 30px; }

/* ---------- Small screens: phone fills the screen, panel becomes a drawer ---------- */
@media (max-width: 760px) {
  body { display: block; }
  #panel {
    position: fixed; z-index: 10; left: 0; top: 0; bottom: 0; width: min(340px, 88vw);
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 10px 0 40px rgba(0, 0, 0, .5);
  }
  body.drawer #panel { transform: none; }
  #stage { height: 100%; width: 100%; }
  #menu {
    display: block; position: fixed; z-index: 9; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(14, 15, 13, .85); color: var(--accent); border: 1px solid var(--line);
    font-size: 18px; backdrop-filter: blur(6px);
  }
  #device { padding: 0; border-radius: 0; box-shadow: none; background: none;
    width: calc(var(--screen-w) * var(--s)); height: calc(var(--screen-h) * var(--s)); }
  #viewport { border-radius: 0; }
}
