:root {
  --navy: #102132;
  --navy-deep: #07121d;
  --orange: #f7941d;
  --white: #ffffff;
  --muted: #b9c4cd;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--navy-deep);
  color: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: calc(12px + var(--safe-top)) 22px 12px;
  border-top: 4px solid var(--orange);
  background: var(--navy);
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
  z-index: 20;
}
.title-block { min-width: 0; }
.eyebrow { margin: 0 0 3px; color: var(--orange); font-size: .7rem; font-weight: 900; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(1.1rem, 2.2vw, 1.65rem); line-height: 1.1; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: .86rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
button {
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.07);
  color: var(--white);
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 4px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
button.accent { border-color: var(--orange); background: var(--orange); color: var(--navy-deep); }
button:hover, button:focus-visible { border-color: var(--orange); background: rgba(247,148,29,.18); }
button.accent:hover, button.accent:focus-visible { background: #ffad42; }
main { position: relative; min-height: 0; overflow: hidden; }
#viewer { position: absolute; inset: 0; background: #02070b; touch-action: none; }
#status {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 30;
  padding: 8px 12px;
  border-left: 3px solid var(--orange);
  background: rgba(7,18,29,.9);
  color: var(--muted);
  font-size: .82rem;
  pointer-events: none;
}
#status.ready { opacity: 0; transition: opacity .8s ease 1.4s; }
#status.error { color: #fff; background: #6f1720; border-color: #ffb3ba; }
.mobile-help { display: none; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 18px calc(8px + var(--safe-bottom));
  background: var(--navy);
  color: var(--muted);
  font-size: .72rem;
}
.openseadragon-container:focus { outline: 3px solid var(--orange); outline-offset: -3px; }
.navigator { border: 2px solid var(--orange) !important; background: #07121d !important; box-shadow: 0 6px 22px rgba(0,0,0,.38); }

@media (max-width: 760px), (pointer: coarse) {
  body { grid-template-rows: 1fr; }
  .topbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 50;
    display: block;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    border-top: 1px solid rgba(255,255,255,.16);
    background: rgba(16,33,50,.97);
    box-shadow: 0 -5px 22px rgba(0,0,0,.38);
  }
  .title-block { display: none; }
  .actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  button {
    min-width: 0;
    min-height: 50px;
    padding: 6px 4px;
    font-size: .78rem;
  }
  main { position: fixed; inset: 0; }
  #viewer { inset: var(--safe-top) 0 calc(66px + var(--safe-bottom)) 0; }
  footer { display: none; }
  #status {
    top: calc(10px + var(--safe-top));
    bottom: auto;
    left: 10px;
    max-width: calc(100vw - 20px);
    font-size: .76rem;
  }
  .mobile-help {
    display: flex;
    flex-direction: column;
    position: absolute;
    z-index: 31;
    left: 50%;
    top: calc(14px + var(--safe-top));
    transform: translateX(-50%);
    min-width: min(86vw, 390px);
    padding: 9px 12px;
    border-left: 4px solid var(--orange);
    background: rgba(7,18,29,.9);
    color: var(--white);
    font-size: .78rem;
    text-align: left;
    pointer-events: none;
    transition: opacity .45s ease;
  }
  .mobile-help span { color: var(--muted); }
  .mobile-help.hide { opacity: 0; }
  .navigator {
    width: 112px !important;
    height: 128px !important;
    right: 8px !important;
    bottom: calc(76px + var(--safe-bottom)) !important;
    left: auto !important;
    top: auto !important;
  }
  .openseadragon-container .openseadragon-canvas:focus { outline: none; }
}
