*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;background:#20262b;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;color:#fff;touch-action:manipulation}
#app{position:fixed;inset:0;z-index:0;touch-action:none}
#app canvas{display:block;cursor:grab;touch-action:none}
#app canvas:active{cursor:grabbing}
#ui{position:fixed;top:max(10px,env(safe-area-inset-top));left:max(10px,env(safe-area-inset-left));right:max(10px,env(safe-area-inset-right));display:flex;flex-wrap:wrap;gap:8px;align-items:center;pointer-events:none;z-index:5}
#ui>*{pointer-events:auto}
#back,#failback{display:inline-flex;align-items:center;gap:6px;min-width:44px;min-height:44px;padding:0 16px 0 12px;border-radius:10px;background:#102a33;color:#f7f1e6;border:1px solid #c4a56a;font-size:16px;font-weight:700;text-decoration:none;box-shadow:0 2px 8px rgba(0,0,0,.35);-webkit-tap-highlight-color:rgba(196,165,106,.4);flex:0 0 auto}
#back span,#failback span{font-size:20px;line-height:1}
#back:active,#failback:active{background:#163844}
#back:focus-visible,#failback:focus-visible{outline:3px solid #f7f1e6;outline-offset:2px}
#back[hidden],.embedded #back,.backlink[hidden],.embedded .backlink{display:none}
#title{background:rgba(10,60,90,.85);padding:8px 12px;border-radius:8px;font-size:14px}
#search{display:flex;gap:6px;align-items:stretch;position:relative;flex:1 1 220px;min-width:0;max-width:420px}
.qwrap{position:relative;flex:1 1 auto;min-width:0}
#q{display:block;width:100%;min-height:44px;padding:8px 44px 8px 10px;border-radius:8px;border:0;font-size:16px}
#search>button{padding:8px 14px;border:0;border-radius:8px;background:#e8467c;color:#fff;font-weight:600;font-size:15px;cursor:pointer;flex:0 0 auto}
#clearq{position:absolute;right:0;top:0;bottom:0;width:44px;padding:0;border:0;background:transparent;color:#102a33;cursor:pointer;display:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent}
#clearq[hidden]{display:none}
#clearq span{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;background:#e2d0b0;font-size:14px;line-height:1;font-weight:700}
#clearq:active span,#clearq:hover span{background:#c4a56a}
#clearq:focus-visible{outline:3px solid #102a33;outline-offset:-4px;border-radius:8px}
#suggest{position:absolute;left:0;right:0;top:calc(100% + 4px);margin:0;padding:6px 0;list-style:none;background:#fff;color:#12202a;border-radius:8px;border:1px solid #9fb4c2;clip-path:inset(0 round 8px);max-height:min(50vh,340px);overflow-y:auto;-webkit-overflow-scrolling:touch;touch-action:pan-y;z-index:20}
#suggest[hidden]{display:none}
#suggest li{padding:10px 14px;font-size:16px;line-height:1.25;min-height:44px;display:flex;align-items:center;justify-content:space-between;gap:8px;cursor:pointer}
#suggest li[aria-selected="true"],#suggest li[data-i]:hover{background:#e8f1f6}
#suggest li .meta{color:#4d6270;font-size:13px;font-weight:600;white-space:nowrap;flex:0 0 auto}
#suggest li .pn{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}
#suggest li .pn small{display:block;color:#4d6270;font-size:12px;margin-top:2px}
#suggest li.hd{min-height:0;padding:8px 14px 4px;font-size:12px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:#4d6270;cursor:default;background:#fff}
#suggest li.prod{padding-top:8px;padding-bottom:8px}
#msg{display:none;flex-flow:column nowrap;align-items:flex-start;flex:0 1 auto;width:max-content;max-width:min(36rem,100%);background:#0f2a33;color:#f7f1e6;border:1px solid #c4a56a;box-shadow:0 2px 10px rgba(0,0,0,.45);padding:10px 14px;border-radius:10px;font-size:18px;line-height:1.35;overflow-wrap:break-word;word-break:normal}
#msg .found-name{font-weight:700;font-size:18px;color:#f7f1e6}
#msg .found-loc{font-weight:700;font-size:20px;color:#e8c57a;margin-top:3px;letter-spacing:.01em}
#msg .found-note{font-size:15px;color:#f7f1e6;margin-top:3px;font-weight:500}
#compass{position:fixed;top:60px;right:12px;background:rgba(0,0,0,.55);padding:6px 10px;border-radius:8px;font-size:13px;z-index:4;pointer-events:none}
#help{position:fixed;bottom:10px;left:50%;transform:translateX(-50%);background:rgba(0,0,0,.55);padding:6px 12px;border-radius:8px;font-size:12px;white-space:nowrap;z-index:4}
#pad{position:fixed;right:14px;bottom:44px;display:none;flex-direction:column;align-items:center;gap:6px;z-index:5}
#pad div{display:flex;gap:6px}
#pad button{width:54px;height:54px;border-radius:12px;border:0;background:rgba(255,255,255,.25);color:#fff;font-size:22px;touch-action:none}
#loading{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;font-size:18px;background:#20262b;z-index:10}
@media (pointer:coarse){
  #pad{display:flex}
  #help{display:none}
}
/* narrow screens: the status/highlight chip gets its own full-width row and the compass chip moves to the bottom-left
   corner, so the two can no longer overlap or push each other off-screen */
@media (max-width:700px){
  #title{font-size:13px;padding:7px 10px;flex:1 1 0;min-width:0;line-height:1.25}
  #search{flex:1 1 100%;max-width:none}
  #msg{flex:0 1 auto;width:max-content;max-width:100%;font-size:17px;padding:10px 12px}
  #msg .found-name{font-size:17px}
  #msg .found-loc{font-size:18px}
  #msg .found-note{font-size:14px}
  #compass{top:auto;right:auto;left:10px;bottom:10px}
  #help{display:none}
}
@media (min-width:701px){
  /* two-line card next to Go is taller than the old chip, so drop the compass below it */
  body.has-msg #compass{top:130px}
}

#texmsg{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);background:rgba(0,0,0,.6);padding:8px 14px;border-radius:8px;font-size:14px;z-index:6;pointer-events:none}
#fail{position:fixed;inset:0;z-index:30;display:flex;align-items:center;justify-content:center;background:rgba(32,38,43,.96);padding:20px}
#fail[hidden]{display:none}
#fail .box{max-width:360px;text-align:center;font-size:16px;line-height:1.45}
#fail .btn{display:inline-block;background:#e8467c;color:#fff;text-decoration:none;font-weight:600;padding:12px 28px;border-radius:8px}

/* ---------- flat fallback (no 3D) ---------- */
html.aisle-flat, html.aisle-flat body {
  height: auto;
  min-height: 100%;
  overflow: auto;
  overflow-x: hidden;
  background: #f7f1e6;
  color: #102a33;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
html.aisle-flat body {
  padding-top: 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
html.aisle-flat #app,
html.aisle-flat #compass,
html.aisle-flat #help,
html.aisle-flat #pad,
html.aisle-flat #loading,
html.aisle-flat #texmsg,
html.aisle-flat #fail { display: none !important; }

html.aisle-flat #ui {
  position: sticky;
  top: 0;
  z-index: 8;
  margin: 0;
  left: auto;
  right: auto;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
  background: #f7f1e6;
  border-bottom: 1px solid #c4a56a;
  box-shadow: 0 8px 18px rgba(16, 42, 51, .06);
}
html.aisle-flat #title {
  background: #102a33;
  color: #f7f1e6;
}
html.aisle-flat #back, html.aisle-flat #failback {
  box-shadow: none;
}
html.aisle-flat #msg { display: none !important; }
html.aisle-flat #search > button { background: #1f5d6b; }
html.aisle-flat #search > button:hover,
html.aisle-flat #search > button:focus-visible { background: #163844; }
html.aisle-flat #q {
  border: 1px solid #c4a56a;
  background: #fffcf7;
  color: #102a33;
}

#flat { display: none; }
html.aisle-flat #flat {
  display: block;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}
.flat-note {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: #efe4d0;
  border: 1px solid #c4a56a;
  border-radius: 10px;
  color: #102a33;
  font-size: 15px;
  line-height: 1.4;
}
.flat-note[hidden] { display: none; }
.flat-lead, .flat-status, .flat-side-lead {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.45;
  color: #1a2428;
}
.flat-status { font-weight: 600; color: #102a33; }
.flat-cats {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: #fffcf7;
  border: 1px solid rgba(16, 42, 51, .14);
  border-left: 4px solid #1f5d6b;
  border-radius: 10px;
}
.flat-cats p { margin: 0 0 6px; font-weight: 700; font-size: 13px; letter-spacing: .03em; text-transform: uppercase; color: #5a6a6e; }
.flat-cats ul { margin: 0; padding: 0; list-style: none; }
.flat-cats li { margin: 0 0 4px; font-size: 15px; }
.flat-cats a { color: #1f5d6b; }
.flat-side { margin: 0 0 28px; }
.flat-side h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 750;
  color: #102a33;
  padding-bottom: 6px;
  border-bottom: 2px solid #c4a56a;
}
.flat-bay { margin: 14px 0 0; scroll-margin-top: 92px; }
.flat-bay h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: #1f5d6b;
}
.flat-bay ul { margin: 0; padding: 0; list-style: none; }
.flat-bay li {
  padding: 10px 12px;
  margin: 0 0 6px;
  background: #fffcf7;
  border: 1px solid rgba(16, 42, 51, .12);
  border-radius: 10px;
}
.flat-bay li.is-hit { border-color: #c4a56a; }
.flat-bay.is-first-hit h3 { color: #8a6a32; }
.flat-name { font-size: 16px; line-height: 1.3; font-weight: 650; color: #102a33; overflow-wrap: anywhere; }
.flat-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; font-size: 13px; color: #5a6a6e; }
.flat-code {
  margin-left: auto;
  font-weight: 700;
  color: #102a33;
  background: #efe4d0;
  border-radius: 6px;
  padding: 1px 7px;
  letter-spacing: .02em;
}
.flat-empty { color: #5a6a6e; font-size: 16px; }
#flat mark {
  background: #f3d58a;
  color: inherit;
  padding: 0 .12em;
  border-radius: 2px;
}

@media (max-width: 700px) {
  html.aisle-flat #flat { padding-top: 12px; }
  .flat-bay { scroll-margin-top: 120px; }
  .flat-name { font-size: 15px; }
}

/* When the document first paints, before JS, keep a cream page if the gate already flagged flat. */
html.aisle-flat #loading { display: none !important; }


/* ---------- List view / Try 3D view ---------- */
.view-btn{
  display:inline-flex;align-items:center;justify-content:center;
  min-height:44px;padding:0 14px;border-radius:10px;
  border:1px solid #c4a56a;background:#102a33;color:#f7f1e6;
  font-size:14px;font-weight:700;cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,.35);
  flex:0 0 auto;margin-left:auto;
  -webkit-tap-highlight-color:rgba(196,165,106,.4);
}
.view-btn:active{background:#163844}
.view-btn:focus-visible{outline:3px solid #f7f1e6;outline-offset:2px}
.view-btn[hidden]{display:none !important}
html.aisle-3d #list-view{
  /* Keep it in the top-right of the 3D chrome, clear of the compass. */
  position:relative;z-index:6;
}
html.aisle-3d #compass{top:max(64px, calc(env(safe-area-inset-top) + 54px))}
@media (max-width:700px){
  html.aisle-3d #compass{top:auto;right:auto;left:10px;bottom:10px}
}
html.aisle-flat .view-btn{
  background:#1f5d6b;color:#fff;border-color:#c4a56a;box-shadow:none;
}
html.aisle-flat .view-btn:active,
html.aisle-flat .view-btn:hover,
html.aisle-flat .view-btn:focus-visible{background:#163844}
html.aisle-flat .view-btn:focus-visible{outline-color:#102a33}

/* v3: unmistakable capital shelf letters (serifed I) */
.flat-loc,.flat-code{font-family:ui-monospace,Menlo,Consolas,"Roboto Mono","DejaVu Sans Mono","Courier New",monospace;text-transform:uppercase;letter-spacing:.04em}
.flat-loc{font-weight:700;color:#2c4650}
.flat-code{font-size:14px}
