*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    height: 100%;
    background: #050505;
    overscroll-behavior: none;
}
body {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.mkiii {
    --navbar-h: 48px;
    --crank-h: 96px;
    position: relative;
    width: 100%;
    max-width: 448px;
    height: 100%;
    max-height: 940px;
    overflow: hidden;
    background-color: #0d0d0d;
    background-image: radial-gradient(circle at 50% 0%, #1e1e1e 0%, #0d0d0d 60%), var(--grain);
    border: 1px solid #333;
    box-shadow:
        0 0 0 1px #000,
        0 24px 60px rgba(0, 0, 0, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.gate {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: calc(var(--navbar-h) + var(--crank-h));
    overflow: hidden;
    background: #000;
    box-shadow: inset 0 -2px 10px rgba(0, 0, 0, 0.9);
}
.magazine {
    position: absolute;
    inset: 0;
    display: flex;
    width: 300%;
    transform: translateX(-33.3333%);
}
.blade {
    width: 33.3333%;
    height: 100%;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}
.blade:empty {
    background: #e9e3d7;
    box-shadow: inset 0 0 26px rgba(120, 105, 75, 0.16);
}
.blade .page {
    transform: scale(var(--page-scale, 1.2059));
    transform-origin: top left;
    min-height: var(--page-unit-h, 546px);
}
#flip {
    position: absolute;
    left: 0; right: 0;
    bottom: var(--navbar-h);
    height: var(--crank-h);
    z-index: 96;
}
.bar {
    width: 100%;
    max-width: 420px;
    height: 34px;
    position: relative;
    background: #060606;
    border-radius: 2px;
    box-shadow:
        inset 0 3px 8px rgba(0, 0, 0, 1),
        inset 0 0 0 1px rgba(0, 0, 0, 0.9),
        0 1px 0 rgba(255, 255, 255, 0.07);
    overflow: hidden;
}
.bar canvas { display: block; width: 100%; height: 100%; }
.navbar .engraving {
    font-family: 'Barlow', sans-serif;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 1.1px;
    white-space: nowrap;
    color: var(--engraved);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
html.dragging, html.dragging * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
    cursor: grabbing !important;
}
.navbar { bottom: var(--crank-h); }
#flip   { bottom: 0; }
.navbar .sync-grid { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); justify-content: stretch; gap: 6px; padding: 0 6px; }
.rack-left, .rack-right { display: flex; align-items: center; gap: 4px; }
.rack-left  { justify-self: start; }
.rack-right { justify-self: end; }
.navbar .read-tube, .navbar .freq-tube { width: var(--side-tube-w, 74px); padding: 0 6px; }
.freq-tube { width: 104px; }
.mkiii { --rail-h: 82px; }
.gearbox-rail { height: var(--rail-h); flex-direction: column; justify-content: center; gap: 8px; padding: 0 12px; }
.tw-overlay { padding-bottom: var(--rail-h); }
.status-tube { width: 100%; max-width: 420px; flex-shrink: 0; }
.wheel-center .lamp-signal {
    position: absolute; left: 50%; top: 50%;
    width: 44px; height: 44px; margin: -22px 0 0 -22px;
    z-index: 10;
}
.tw-overlay {
    overflow: hidden;
    background: rgba(8, 10, 13, 0.22);
    backdrop-filter: blur(4px) saturate(0.7) brightness(0.8);
    -webkit-backdrop-filter: blur(4px) saturate(0.7) brightness(0.8);
}
.tw-overlay::before {
    content: '';
    position: absolute;
    inset: -192px;
    background-image: var(--static-tile, none);
    background-size: 192px 192px;
    opacity: var(--static-amount, 0.5);
    transition: opacity 0.18s linear;
    mix-blend-mode: normal;
    pointer-events: none;
    will-change: transform;
    animation: glass-static 0.5s steps(1, end) infinite;
    z-index: 0;
}
.tw-overlay > * { position: relative; z-index: 1; }
.tw-overlay > .gearbox-rail { position: absolute; }
@keyframes glass-static {
    0%    { transform: translate(0, 0); }
    16.6% { transform: translate(-71px, 37px); }
    33.3% { transform: translate(53px, -113px); }
    50%   { transform: translate(-149px, -29px); }
    66.6% { transform: translate(97px, 131px); }
    83.3% { transform: translate(-23px, 83px); }
}
.navbar .rail-card { font-size: 9px; letter-spacing: 1.8px; text-indent: 1.8px; padding: 3px 8px; }
.navbar .read-tube .lcd-text, .navbar .freq-tube .lcd-text { font-size: 10px; letter-spacing: 0.2px; }
.navbar .caliper-btn { min-width: 50px; padding: 0 8px; }
.crank-rail {
    background: repeating-linear-gradient(0deg, #4a4a4c 0 1px, #3a3a3c 1px 2px), linear-gradient(180deg, #4c4c4e, #2c2c2e);
    background-blend-mode: overlay;
    border-top: 0;
    border-bottom: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25), inset 0 -1px 0 #000, 0 -3px 12px rgba(0,0,0,.6);
}
.crank-screw { position: absolute; width: 5px; height: 5px; border-radius: 50%; z-index: 22; pointer-events: none;
    background: radial-gradient(circle at 40% 35%, #9a9a9a, #3a3a3a 70%); box-shadow: 0 0 0 1px #111; }
.crank-screw::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: #111; transform: rotate(35deg); }
.crank-screw.tl { top: 5px; left: 6px; } .crank-screw.tr { top: 5px; right: 5px; } .crank-screw.bl { bottom: 5px; left: 6px; } .crank-screw.br { bottom: 5px; right: 5px; }
.crank-slot {
    top: 48px;
    height: 10px;
    margin-top: -5px;
    left: 30px; right: 30px;
    background: #050505;
    border-radius: 5px;
    border: 0;
    box-shadow: inset 0 0 0 1px #000, inset 2px 2px 5px rgba(0, 0, 0, 0.95), 0 1px 0 rgba(255, 255, 255, 0.18), 0 -1px 0 rgba(0, 0, 0, 0.6);
}
.crank-detent {
    top: 48px;
    width: 6px; height: 18px;
    margin: -9px 0 0 -3px;
    border-radius: 2px;
    background: #050505;
    box-shadow: inset 0 0 0 1px #000, inset 1px 2px 3px rgba(0, 0, 0, 0.95), 0 1px 0 rgba(255, 255, 255, 0.18);
}
.crank-stop {
    position: absolute;
    top: 48px;
    width: 8px; height: 22px;
    margin-top: -11px;
    border-radius: 2px;
    background: linear-gradient(to bottom, #262626 0%, #4c4c4c 48%, #444 56%, #242424 100%);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 0 1px #0a0a0a;
    pointer-events: none;
    z-index: 30;
}
.crank-stop.left  { left: 22px; }
.crank-stop.right { right: 22px; }
.caliper-indicator { cursor: default; pointer-events: none; }
