:root {
  --navy: #0b1728;
  --navy-soft: #13243a;
  --paper: #f1eee7;
  --gold: #c69b49;
  --line: rgba(241, 238, 231, 0.17);
  --muted: rgba(241, 238, 231, 0.68);
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #14171b;
  color: var(--paper);
  font-family: "Archivo", sans-serif;
}

.viewer-bar {
  position: relative;
  z-index: 2;
  min-height: 116px;
  display: grid;
  grid-template-columns: minmax(160px, 0.55fr) minmax(280px, 1.4fr) auto;
  align-items: center;
  gap: clamp(20px, 3vw, 48px);
  padding: 17px clamp(18px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--navy);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.viewer-brand {
  width: clamp(138px, 14vw, 210px);
  display: block;
}

.viewer-brand img {
  display: block;
  width: 100%;
  height: auto;
}

.viewer-title { min-width: 0; }

.viewer-title h1 {
  margin: 0;
  overflow: hidden;
  color: var(--paper);
  font: 400 clamp(23px, 2.2vw, 34px)/1.05 "Newsreader", serif;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.viewer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.viewer-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  font: 600 10px/1 "Archivo", sans-serif;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.viewer-action:hover,
.viewer-action:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.viewer-action-primary {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--navy);
}

.viewer-action-primary:hover,
.viewer-action-primary:focus-visible {
  background: #ddb96d;
  color: var(--navy);
}

.viewer-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #24272c;
}

.viewer-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  border: 0;
  background: #33363b;
}

.viewer-loading,
.viewer-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  background: #24272c;
  color: rgba(255, 255, 255, 0.66);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
}

.viewer-loading.is-hidden { display: none; }

.viewer-fallback {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 18px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--navy);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.viewer-fallback a {
  color: var(--paper);
  text-underline-offset: 3px;
}

@media (max-width: 980px) {
  body { overflow: auto; }

  .viewer-bar {
    grid-template-columns: 1fr auto;
    min-height: 0;
    gap: 15px 20px;
  }

  .viewer-brand { width: 145px; }
  .viewer-title { grid-column: 1 / -1; grid-row: 2; }
  .viewer-actions { grid-column: 2; grid-row: 1; }
  .viewer-action-optional { display: none; }
  .viewer-stage { min-height: 72dvh; }
  .viewer-frame { min-height: 72dvh; }
}

@media (max-width: 560px) {
  .viewer-bar { padding: 14px 16px 16px; }
  .viewer-brand { width: 126px; }
  .viewer-title h1 { font-size: 23px; white-space: normal; }
  .viewer-title p { line-height: 1.45; }
  .viewer-action { min-height: 38px; padding: 0 12px; }
  .viewer-fallback { flex-wrap: wrap; }
  .viewer-stage, .viewer-frame { min-height: 68dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-action { transition: none; }
}
