/* Usable minimum only: sizes, spacing, hit targets, readable states. Visual design comes later. */
* { box-sizing: border-box; }
[hidden] { display: none !important; } /* elements with display:flex/grid must still hide */
html, body { height: 100%; }
body {
  margin: 0; font: 16px/1.6 system-ui, -apple-system, "Hiragino Sans", sans-serif;
  background: Canvas; color: CanvasText;
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 24px;
}
button { font: inherit; cursor: pointer; padding: 8px 16px; border-radius: 8px; border: 1px solid GrayText; background: Canvas; color: CanvasText; }
button:focus-visible { outline: 2px solid Highlight; outline-offset: 2px; }

header { width: 100%; max-width: 960px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
/* Mac page: full-width title bar (Take's sketch, 2026-10-01) */
#top {
  max-width: none; width: calc(100% + 48px); margin: -16px -24px 0; padding: 16px 24px;
  border-bottom: 2px solid CanvasText; font: 500 20px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
}
/* Direction switch centered, the gear at the right edge of the same row */
#toprow { position: relative; width: 100%; display: flex; justify-content: center; align-items: center; margin-top: 28px; min-height: 56px; }
/* Wireframe: the gear is a small circle */
#gear { position: absolute; right: 8px; width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 3px solid GrayText; }

/* Direction switch (M1 / M6 / M7) */
#direction { display: flex; border: 3px solid CanvasText; overflow: hidden; }
#direction button { border: 0; border-radius: 0; padding: 12px 24px; font-size: 20px; }
#direction [aria-checked="true"] { background: CanvasText; color: Canvas; font-weight: 600; }

main#stage {
  flex: 1; width: 100%; max-width: 960px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
}
/* Wireframe picto: the iPhone's edge (a rectangle open at the bottom) + ↓, above the bar */
#picto { display: flex; flex-direction: column; align-items: center; gap: 4px; animation: drop 1.6s ease-in-out infinite; }
#picto .edge { width: 110px; height: 38px; border: 3px solid CanvasText; border-bottom: 0; border-radius: 12px 12px 0 0; }
#picto .arrow { font-size: 26px; line-height: 1; }
@keyframes drop { 0%, 100% { transform: translateY(-12px); opacity: .4; } 50% { transform: translateY(8px); opacity: 1; } }
#bar { position: relative; width: min(680px, 90%); }
#spacebar {
  width: 100%; height: 92px; border: 3px solid CanvasText; border-radius: 12px;
}
/* The hand + iPhone over the bar's left end. Coordinates are in the SVG's own units:
   the bar's top-left sits at (222, 90) of the 580×430 viewBox. */
#hand {
  position: absolute; left: -222px; top: -90px; width: 580px; height: 430px;
  overflow: visible; pointer-events: none; color: CanvasText;
}
#hand .line { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
#hand .phone { fill: Canvas; stroke: currentColor; stroke-width: 2.5; }
#hand .phone { fill: color-mix(in srgb, CanvasText 15%, Canvas); }
#hand .tap { animation: tap 2.4s ease-in-out infinite; transform-origin: 368px 250px; }
@keyframes tap {
  0%, 55%, 100% { transform: translate(-10px, -18px) rotate(-3deg); }
  70% { transform: translate(0, 0) rotate(0); }
  76% { transform: translate(-3px, -5px) rotate(-1deg); }
  84% { transform: translate(0, 0) rotate(0); }
}
/* Hidden where it would run off the left edge */
@media (max-width: 900px) { #hand { display: none; } }
#spacebar.dashed { border-style: dashed; } /* M3 */
#spacebar.off { border-color: GrayText; } /* M5 */
#spacebar.shake { animation: tilt .5s; } /* M4 */
@keyframes tilt { 25% { transform: rotate(-2deg) translateX(-6px); } 75% { transform: rotate(2deg) translateX(6px); } }
#caption { font-size: 28px; margin: 0; min-height: 1.6em; text-align: center; }

/* M2: what arrived */
#arrived { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
#arrived p { margin: 0; }
#arrived .note { color: GrayText; font-size: 14px; }
#arrived .keys { display: flex; gap: 12px; }
#arrivedBody pre, #outboxBody pre {
  max-width: min(640px, 90vw); max-height: 30vh; overflow: auto; white-space: pre-wrap; text-align: left;
  margin: 0; padding: 12px 16px; border: 1px solid GrayText; border-radius: 8px; font: inherit;
}
kbd { width: 56px; height: 56px; display: grid; place-items: center; border: 2px solid CanvasText; border-radius: 10px; font: 700 22px system-ui; }
img { max-width: min(480px, 80vw); max-height: 30vh; border-radius: 8px; display: block; }

/* M6 / M7: drop spot */
#outbox { width: min(640px, 90%); }
#outboxEmpty {
  border: 2px dashed GrayText; border-radius: 12px; padding: 40px 16px; text-align: center; color: GrayText;
}
#outboxItem { position: relative; display: flex; justify-content: center; }
#outboxClear { position: absolute; top: -12px; right: -12px; border-radius: 50%; width: 36px; height: 36px; padding: 0; }

/* M3: tab not focused */
#unfocused {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); color: #fff; font-size: 24px;
  display: grid; place-items: center; cursor: pointer; z-index: 500;
}

/* M9: settings */
#settings {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100%); overflow: auto; z-index: 600;
  background: Canvas; border-left: 1px solid GrayText; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
#settings h2 { margin: 0; font-size: 20px; }
#settings h3 { margin: 0 0 4px; font-size: 14px; color: GrayText; }
#history { margin: 0; padding-left: 20px; max-height: 50vh; overflow: auto; }

/* M4 / M10 */
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Dev: always on, bottom-right, never blocks clicks */
#dev {
  position: fixed; right: 0; bottom: 0; z-index: 1000; max-width: 360px; max-height: 45vh; overflow: hidden;
  font: 11px/1.4 ui-monospace, monospace; background: rgba(0, 0, 0, .8); color: #0f0; padding: 6px;
  pointer-events: none;
}
#dev table { border-collapse: collapse; }
#dev th { text-align: left; padding-right: 8px; font-weight: normal; color: #8f8; }
#dev pre { margin: 6px 0 0; white-space: pre-wrap; max-height: 12vh; overflow: hidden; font: inherit; }

@media (prefers-reduced-motion: reduce) { #picto, .shake, #hand .tap { animation: none; } }
