*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #AE3E06;
  --white: #FFFFFF;
  --font-serif: "Playfair Display", Georgia, serif;
  --font-sans: "DM Sans", "Avenir Next", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
  --radius: 8px;
  --hairline: 1px;
  --shadow: 0 16px 40px rgba(174, 62, 6, 0.12);
  --muted-brand: rgba(174, 62, 6, 0.62);
  --soft-brand: rgba(174, 62, 6, 0.08);
}

html { min-height: 100%; background: var(--white); color: var(--brand); }
body {
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--white);
  color: var(--brand);
  line-height: 1.5;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 5.5rem;
  right: max(1.5rem, calc((100vw - 960px) / 2));
  width: clamp(116px, 18vw, 172px);
  aspect-ratio: 1;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(rgba(174, 62, 6, 0.35), rgba(174, 62, 6, 0.35)) center / 1px 100% no-repeat,
    linear-gradient(90deg, rgba(174, 62, 6, 0.35), rgba(174, 62, 6, 0.35)) center / 100% 1px no-repeat,
    radial-gradient(circle,
      var(--brand) 0 2px,
      var(--white) 2px 25%,
      var(--brand) 25% calc(25% + 1px),
      var(--white) calc(25% + 1px) 50%,
      var(--brand) 50% calc(50% + 1px),
      var(--white) calc(50% + 1px) 75%,
      var(--brand) 75% calc(75% + 1px),
      var(--white) calc(75% + 1px) calc(100% - 1px),
      var(--brand) calc(100% - 1px) 100%);
}

a { color: var(--brand); text-decoration: underline; text-decoration-thickness: var(--hairline); text-underline-offset: 0.18em; }
a:hover { text-decoration-style: dashed; }
button, input, select { font: inherit; color: inherit; }
button { border-radius: var(--radius); }
::placeholder { color: var(--muted-brand); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2.25rem 1rem;
}

.nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  background: var(--white);
  border-bottom: var(--hairline) solid var(--brand);
}

.nav-brand {
  text-decoration: none;
}

.brand-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: var(--brand);
  text-decoration: none;
}

.brand-wordmark img {
  display: block;
  width: clamp(138px, 15vw, 188px);
  height: clamp(25px, 2.7vw, 34px);
  object-fit: contain;
}

.brand-wordmark span {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0;
  line-height: 1;
  text-transform: uppercase;
  padding: 0.28rem 0.42rem;
  border: var(--hairline) solid var(--brand);
  border-radius: 999px;
}

.nav-logout button,
.btn,
.viewer-nav button {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border: var(--hairline) solid var(--brand);
  background: var(--white);
  color: var(--brand);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.nav-logout button:hover,
.btn:hover,
.viewer-nav button:hover {
  background: var(--brand);
  color: var(--white);
}

.btn-primary,
.auth-form button,
.auth-form .auth-button,
.gate-card button {
  background: var(--brand);
  color: var(--white);
  border-color: var(--brand);
}

.btn-primary:hover,
.auth-form button:hover,
.auth-form .auth-button:hover,
.gate-card button:hover {
  background: var(--white);
  color: var(--brand);
}

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.76rem; }
.btn-xs { padding: 0.2rem 0.45rem; font-size: 0.68rem; }

.auth-form,
.gate-card {
  max-width: 400px;
  width: 100%;
  padding: 2rem;
  background: var(--white);
  border: var(--hairline) solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-form {
  margin: 4rem auto;
}

.auth-form h1,
.gate-card h1,
.dashboard-header h1,
.doc-detail-header h1,
.section h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--brand);
  line-height: 1.05;
}

.auth-form h1 { margin-bottom: 1.5rem; font-size: 3rem; }
.gate-card h1 { margin-bottom: 0.75rem; font-size: 3rem; }
.dashboard-header h1,
.doc-detail-header h1 { font-size: 4.5rem; max-width: 12ch; }
.section h2 { margin-bottom: 1rem; font-size: 1.7rem; }

.auth-form label,
.gate-card label {
  display: block;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-form input,
.gate-card input,
.doc-tag-controls input,
.select-control select {
  display: block;
  width: 100%;
  padding: 0.62rem 0.7rem;
  margin-top: 0.35rem;
  border: var(--hairline) solid var(--brand);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--brand);
  font-family: var(--font-sans);
  font-size: 0.96rem;
}

.select-control select {
  width: auto;
  min-width: 8.6rem;
  margin-top: 0;
  appearance: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-form button,
.auth-form .auth-button,
.gate-card button {
  width: 100%;
  display: block;
  padding: 0.68rem;
  border: var(--hairline) solid var(--brand);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

.auth-link {
  text-align: left;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
}

.error {
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  background: var(--white);
  border: var(--hairline) dashed var(--brand);
  border-radius: var(--radius);
}

.dashboard-header,
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.dashboard-header { margin-bottom: 2rem; }
.section-header { align-items: center; margin-bottom: 1rem; }

.doc-list,
.link-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.doc-card,
.link-card,
.metric-strip > div {
  background: var(--white);
  border: var(--hairline) solid var(--brand);
  border-radius: var(--radius);
  color: var(--brand);
}

.doc-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
}

.doc-card:hover,
.link-card:hover {
  border-style: dashed;
}

.doc-card-title {
  display: inline-block;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-decoration-thickness: var(--hairline);
}

.doc-card-copy {
  min-width: 0;
}

.doc-card-actions,
.doc-detail-topline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.doc-card-filename {
  max-width: 100%;
  margin-top: 0.35rem;
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.doc-detail-topline {
  margin-bottom: 1rem;
}

.doc-card-tag,
.vpn-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 0.45rem;
  padding: 0.16rem 0.42rem;
  border: var(--hairline) solid var(--brand);
  border-radius: 999px;
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
}

.doc-card-meta,
.doc-meta,
.link-meta,
.metric-label,
.viewer-table th,
#page-info {
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.doc-card-meta,
.doc-meta,
.link-meta {
  margin-top: 0.35rem;
}

.empty-state {
  border: var(--hairline) dashed var(--brand);
  border-radius: var(--radius);
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 2rem;
  text-align: center;
  text-transform: uppercase;
}

.doc-detail-header { margin-bottom: 2rem; max-width: 680px; }

.doc-tag-form,
.doc-version-form,
.link-tag-form {
  display: grid;
  gap: 0.4rem;
  max-width: 420px;
  margin-top: 1.1rem;
}

.doc-tag-form label,
.doc-version-form label,
.link-tag-form label,
.select-control span {
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.doc-tag-controls,
.doc-version-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.section-actions,
.link-settings {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.select-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.metric-strip > div { padding: 0.85rem; }
.metric-value {
  display: block;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 1.1;
}
.metric-label { display: block; margin-top: 0.35rem; font-weight: 700; }

.section { margin-bottom: 2rem; }

.link-card { padding: 0.85rem; }
.link-card.inactive { border-style: dashed; }
.link-url { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.35rem; }
.link-url code {
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--brand);
}
.link-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.link-settings {
  justify-content: space-between;
  margin-bottom: 0.45rem;
  align-items: end;
}
.link-tag-form {
  flex: 1 1 22rem;
  max-width: 32rem;
  margin-top: 0;
}
.link-tag-form .doc-tag-controls {
  min-width: min(100%, 22rem);
}
.link-passcode-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.link-passcode-label,
.link-passcode-note {
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}
.link-passcode-value {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 0.16rem 0.42rem;
  border: var(--hairline) solid var(--brand);
  border-radius: 999px;
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.25;
}
.link-passcode-note {
  color: var(--muted-brand);
}
.inactive-badge { color: var(--brand); font-weight: 700; text-transform: uppercase; }

.link-viewers,
.link-click-details {
  margin-top: 0.85rem;
  border-top: var(--hairline) solid var(--brand);
}

.link-viewers summary,
.link-click-details summary {
  cursor: pointer;
  list-style: none;
  padding: 0.72rem 0 0.22rem;
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.link-viewers summary::-webkit-details-marker,
.link-click-details summary::-webkit-details-marker {
  display: none;
}

.link-viewers summary::after,
.link-click-details summary::after {
  content: "+";
  display: inline-block;
  margin-left: 0.4rem;
}

.link-viewers[open] summary::after,
.link-click-details[open] summary::after {
  content: "-";
}

.link-viewers-empty {
  display: block;
  padding: 0.65rem 0 0.2rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.link-viewer-table,
.link-click-table {
  margin-top: 0.4rem;
}

.link-click-table a {
  overflow-wrap: anywhere;
}

.time-compact {
  display: inline-block;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: normal;
}

.time-cell {
  max-width: 9.5rem;
  min-width: 7.5rem;
  white-space: normal;
}

.empty-inline {
  color: var(--muted-brand);
  font-size: 0.8rem;
}

.page-activity-graph {
  display: grid;
  gap: 0.35rem;
  list-style: none;
  min-width: 18rem;
}

.page-activity-graph li {
  display: grid;
  grid-template-columns: 2.2rem minmax(6rem, 1fr) minmax(6.5rem, auto);
  align-items: center;
  gap: 0.5rem;
}

.page-activity-label,
.page-activity-value {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.2;
}

.page-activity-value {
  color: var(--muted-brand);
  text-align: right;
  white-space: nowrap;
}

.page-activity-graph meter {
  display: block;
  width: 100%;
  height: 0.48rem;
  border: var(--hairline) solid var(--brand);
  border-radius: 999px;
  background: var(--white);
}

.page-activity-graph meter::-webkit-meter-bar {
  background: var(--white);
  border: 0;
  border-radius: 999px;
}

.page-activity-graph meter::-webkit-meter-optimum-value {
  background: var(--brand);
  border-radius: 999px;
}

.page-activity-graph meter::-moz-meter-bar {
  background: var(--brand);
  border-radius: 999px;
}

.viewer-table {
  width: 100%;
  border-collapse: collapse;
  border-top: var(--hairline) solid var(--brand);
}

.viewer-table th,
.viewer-table td {
  padding: 0.62rem 0.5rem;
  text-align: left;
  border-bottom: var(--hairline) solid var(--brand);
  font-size: 0.875rem;
  vertical-align: top;
}

.viewer-table th { font-weight: 700; }

.viewer-location {
  display: grid;
  gap: 0.3rem;
  min-width: 8rem;
}

.vpn-badge {
  margin-top: 0;
  border-style: dashed;
}

.gate-body {
  --gate-band-height: clamp(13.5rem, 34vh, 21rem);
  background:
    linear-gradient(90deg, transparent 0 50%, rgba(174, 62, 6, 0.18) 50% calc(50% + 1px), transparent calc(50% + 1px) 100%),
    linear-gradient(180deg, var(--brand) 0 var(--gate-band-height), var(--white) var(--gate-band-height) 100%);
  overflow: hidden;
}

.gate-body::before {
  display: none;
}

.gate-artifacts {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.gate-artifacts img {
  position: absolute;
  display: block;
  user-select: none;
}

.gate-denoise {
  top: clamp(1.8rem, 8vh, 4.8rem);
  left: max(1.25rem, calc(50vw - 31rem));
  width: clamp(13rem, 22vw, 22rem);
  height: auto;
  opacity: 0.78;
}

.gate-schedule {
  right: max(1.25rem, calc(50vw - 30rem));
  bottom: clamp(1.5rem, 6vh, 4rem);
  width: clamp(13rem, 21vw, 19rem);
  height: auto;
  opacity: 0.48;
}

.gate-pie {
  left: max(1rem, calc(50vw - 30rem));
  bottom: clamp(1.4rem, 7vh, 4.8rem);
  width: clamp(7rem, 11vw, 10rem);
  height: auto;
  opacity: 0.46;
}

.gate-ruler {
  top: 0;
  left: 0;
  width: min(26vw, 24rem);
  height: 100vh;
  object-fit: cover;
  object-position: left center;
  opacity: 0.28;
}

.gate-container {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.gate-card {
  max-width: 460px;
  width: 100%;
  padding: clamp(1.35rem, 4vw, 2.2rem);
}

.gate-mark {
  display: block;
  width: 86px;
  height: 82px;
  margin: 0 auto 1.45rem;
  border-radius: 8px;
  object-fit: cover;
}

.bagel-loader-mark {
  display: block;
  width: 86px;
  height: 82px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 14px 34px rgba(174, 62, 6, 0.18);
  animation: bagel-loader-bounce 1.24s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

.bagel-loader-mark-sm {
  width: 1.12rem;
  height: 1.06rem;
  border-radius: 4px;
  box-shadow: none;
}

@keyframes bagel-loader-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  44% {
    transform: translateY(-11px) scale(1.04);
  }
  60% {
    transform: translateY(0) scale(0.98);
  }
  76% {
    transform: translateY(-4px) scale(1.01);
  }
}

.gate-field {
  margin-bottom: 0.8rem;
}

.gate-form.is-submitting .gate-submit-idle {
  display: none;
}

.gate-submit-loading {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
}

.gate-form.is-submitting .gate-submit-loading {
  display: inline-flex;
}

.gate-card button:disabled,
.gate-card button[aria-busy="true"],
.gate-card button:disabled:hover,
.gate-card button[aria-busy="true"]:hover {
  background: var(--brand);
  color: var(--white);
  cursor: progress;
}

.gate-submit-status {
  display: grid;
  justify-items: center;
  gap: 0.62rem;
  margin-top: 1rem;
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.gate-submit-status[hidden] {
  display: none;
}

.gate-submit-status .bagel-loader-mark {
  width: 64px;
  height: 61px;
}

.gate-instruction {
  max-width: 18rem;
  margin: 0 auto 1.05rem;
  color: var(--brand);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
}

.gate-card .gate-eyebrow {
  margin-bottom: 0.65rem;
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.gate-card p:not(.gate-eyebrow):not(.error) {
  color: var(--brand);
  max-width: 31rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.viewer-body {
  overflow: hidden;
}

.viewer-body::before {
  display: none;
}

.viewer-container {
  position: relative;
  z-index: 1;
  overflow: hidden;
  height: 100dvh;
  min-height: 100vh;
  background: var(--white);
}

.viewer-toolbar {
  position: fixed;
  inset: max(0.35rem, env(safe-area-inset-top)) max(2px, env(safe-area-inset-right)) auto max(2px, env(safe-area-inset-left));
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0;
  pointer-events: none;
}

.viewer-heading {
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 0;
  min-width: 0;
  max-width: min(24vw, 7rem);
  padding: 0.24rem 0.32rem;
  background: rgba(255, 255, 255, 0.9);
  border: var(--hairline) solid var(--brand);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(174, 62, 6, 0.08);
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.viewer-brand img {
  width: clamp(62px, 5vw, 86px);
  height: clamp(11px, 0.95vw, 16px);
}

.viewer-brand span {
  display: none;
}

.viewer-title {
  display: none;
}

.viewer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0.24rem;
  background: rgba(255, 255, 255, 0.9);
  border: var(--hairline) solid var(--brand);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(174, 62, 6, 0.08);
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.viewer-nav { display: flex; align-items: center; gap: 0.5rem; }
.viewer-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 999px;
}

#page-info {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  white-space: nowrap;
}

.viewer-nav button:disabled {
  background: var(--white);
  color: var(--brand);
  border-style: dashed;
  cursor: default;
}

.viewer-canvas-wrapper {
  position: fixed;
  inset: 0;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--white), var(--soft-brand));
  padding: clamp(2px, 0.6vmin, 8px);
}

.viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.82rem;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 245, 241, 0.94));
  color: var(--brand);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
}

.viewer-loading[hidden] {
  display: none;
}

.viewer-loading .bagel-loader-mark {
  width: clamp(72px, 10vmin, 96px);
  height: clamp(69px, 9.6vmin, 92px);
}

.pdf-page {
  position: relative;
  max-width: 100%;
  border: 0;
  outline: var(--hairline) solid var(--brand);
  box-shadow: 0 10px 34px rgba(174, 62, 6, 0.14);
  line-height: 0;
  background: var(--white);
}

#pdf-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.pdf-link-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.pdf-link {
  position: absolute;
  display: block;
  border-radius: 2px;
  pointer-events: auto;
  text-decoration: none;
}

.pdf-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

input:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  body::before { width: 112px; top: 5rem; right: 1rem; }
  .container { padding: 1.5rem 1rem; }
  .nav { padding: 0.75rem 1rem; }
  .auth-form { margin: 3rem auto; }
  .auth-form h1,
  .gate-card h1 { font-size: 2.35rem; }
  .dashboard-header h1,
  .doc-detail-header h1 { font-size: 2.85rem; }
  .dashboard-header { align-items: flex-start; flex-direction: column; }
  .doc-card { flex-direction: column; }
  .doc-card-actions { width: 100%; }
  .doc-card-actions .btn { flex: 1 1 8rem; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viewer-table { display: block; overflow-x: auto; white-space: nowrap; }
  .viewer-table .time-cell { white-space: normal; }
  .link-url { align-items: flex-start; flex-direction: column; }
  .link-settings { justify-content: flex-start; }
  .link-actions { width: 100%; }
  .doc-tag-controls { grid-template-columns: 1fr; }
  .section-actions { width: 100%; justify-content: space-between; }
  .viewer-toolbar { align-items: start; gap: 0.35rem; }
  .viewer-heading {
    padding: 0.22rem 0.3rem;
  }
  .viewer-actions { justify-content: space-between; }
  .viewer-brand img { display: none; }
  .viewer-brand span { display: block; }
  .brand-wordmark span { font-size: 0.68rem; }
  .viewer-nav { gap: 0.25rem; }
  .viewer-nav button { width: 1.9rem; height: 1.9rem; }
  #page-info { font-size: 0.66rem; }
  .page-activity-graph { min-width: 16rem; }
  .gate-body { --gate-band-height: clamp(10rem, 30vh, 13rem); }
  .gate-ruler { display: none; }
  .gate-denoise {
    top: 1.25rem;
    left: 50%;
    width: min(68vw, 14rem);
    transform: translateX(-50%);
    opacity: 0.56;
  }
  .gate-pie {
    left: auto;
    right: -2.6rem;
    bottom: calc(var(--gate-band-height) + 0.75rem);
    width: 7.5rem;
    opacity: 0.24;
  }
  .gate-schedule {
    left: -1.2rem;
    right: auto;
    bottom: 0.9rem;
    width: 11rem;
    opacity: 0.22;
  }
}

@media (max-width: 420px) {
  .gate-container { padding: 0.85rem; }
  .gate-card { padding: 1.15rem; }
  .gate-mark {
    width: 72px;
    height: 69px;
    margin-bottom: 1rem;
  }
  .gate-schedule { display: none; }
}

@media (max-height: 620px) {
  .gate-body { --gate-band-height: clamp(8rem, 28vh, 10.5rem); }
  .gate-container {
    align-items: center;
    padding-block: 0.75rem;
  }
  .gate-mark {
    width: 68px;
    height: 65px;
    margin-bottom: 0.9rem;
  }
  .gate-schedule,
  .gate-pie {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bagel-loader-mark {
    animation: none;
  }
}

@media (min-width: 1280px) {
  .gate-denoise { left: max(4rem, calc(50vw - 36rem)); }
  .gate-pie { left: max(4rem, calc(50vw - 36rem)); }
  .gate-schedule { right: max(4rem, calc(50vw - 36rem)); }
}
