:root {
  color-scheme: dark;
  --accent: #F9B04D;
  --r2-message: #673B00;
  --user-message: #323232;
  --text: #f7f5f1;
  --muted: #a5a5a5;
  --line: #F9B04D;
  --black: #000;
  --page-pad-x: clamp(24px, 3.2vw, 48px);
  --page-pad-y: clamp(24px, 5.6vh, 48px);
  --footer-height: 28px;
  --experience-gap: 24px;
  --chat-panel-width: 410px;
  --presentation-max-width: calc((var(--app-height) - var(--footer-height) - 24px - 52px) * 16 / 9);
  --app-width: calc(100% - var(--page-pad-x) * 2);
  --app-height: calc(100vh - var(--page-pad-y) * 2);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--black);
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background: var(--black);
}

body.auth-checking .app-shell,
body.auth-required .app-shell,
body.sas-thank-you .app-shell {
  visibility: hidden;
  pointer-events: none;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: var(--app-width);
  height: var(--app-height);
  min-height: 0;
  margin: var(--page-pad-y) auto;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--footer-height);
  gap: clamp(12px, 2.8vh, 24px);
  padding: 0;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 24px;
  background: #000;
}

body.auth-checking .auth-gate,
body.auth-required .auth-gate,
body.sas-thank-you .auth-gate {
  display: grid;
}

.auth-contact {
  display: grid;
  gap: 10px;
}

.auth-contact-label {
  color: #b8b8b8;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-contact-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 32px;
}

.auth-contact-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #e7e7e7;
  font-size: 15px;
  font-weight: 600;
}

/* Scoped under .auth-card so it overrides the logo's ".auth-card img" rule. */
.auth-card .auth-contact-icon {
  width: 28px;
  height: 28px;
  margin: 0;
  object-fit: contain;
}

.auth-contact-link:hover span,
.auth-contact-link:focus-visible span {
  text-decoration: underline;
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(184, 184, 184, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #f7f5f1;
}

.auth-card img {
  width: 148px;
  height: auto;
  margin-bottom: 28px;
}

.auth-card h1 {
  margin: 0 0 10px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 24px;
  line-height: 1.1;
}

.auth-card p {
  margin: 0 0 22px;
  color: #b8b8b8;
  font-size: 15px;
  line-height: 1.45;
}

.auth-login-btn {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(184, 184, 184, 0.42);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #e7e7e7;
  font-size: 14px;
  font-weight: 600;
}

.auth-login-btn:not(:disabled):hover,
.auth-login-btn:not(:disabled):focus-visible {
  border-color: rgba(231, 231, 231, 0.62);
  background: rgba(255, 255, 255, 0.1);
}

.experience {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, min(calc(var(--app-width) - var(--chat-panel-width) - var(--experience-gap)), var(--presentation-max-width))) minmax(320px, var(--chat-panel-width));
  gap: var(--experience-gap);
  justify-content: center;
  align-items: start;
}

.presentation-area {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 14px;
  align-content: start;
  justify-self: stretch;
}

.stage-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 0;
  background: #050505;
  border: 1px solid var(--line);
}

.slide-canvas {
  position: absolute;
  inset: 0;
}

.slide-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.youtube-layer {
  position: absolute;
  z-index: 5;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

.youtube-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.avatar-dock {
  position: absolute;
  right: -9%;
  bottom: 0%;
  z-index: 8;
  width: 38%;
  aspect-ratio: 16 / 9;
  pointer-events: none;
}

.avatar-dock canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* EMOJI_ANIMATION mode: a square emoji bubble bottom-right instead of the
   LiveKit canvas. clamp() keeps it sensible across breakpoints so it does not
   need per-media-query overrides. */
.emoji-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.emoji-avatar[hidden] {
  display: none;
}

body.avatar-mode-emoji .avatar-dock {
  right: 2%;
  bottom: 2%;
  width: clamp(120px, 22%, 240px);
  aspect-ratio: 1 / 1;
}

body.avatar-mode-emoji .avatar-dock canvas {
  display: none;
}

/* VIDEO_AVATAR mode: the green-screen MP4 is chroma-keyed onto the same canvas
   the LiveKit avatar uses. */
body.avatar-mode-video .avatar-dock canvas {
  display: block;
}

/* Size & position of the VIDEO_AVATAR only (does not touch LIVE_AVATAR/emoji).
   - width: overall size; the height follows the clip's aspect automatically
     (the aspect-ratio is set from the MP4 in JS, so do NOT set it here).
   - right/bottom: where it sits in the slide (swap for left/top if preferred).
   Negative right lets the avatar bleed off the slide edge. */
body.avatar-mode-video .avatar-dock {
  width: 16%;
  right: -1%;
  bottom: 0%;
}

.presentation-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.start-btn {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  color: #dcdcdc;
  font-size: 14px;
  font-weight: 500;
}

.start-btn img,
.round-btn img,
.send-btn img,
.mic-btn img {
  display: block;
  width: 28px;
  height: 28px;
}

.start-btn img,
.round-btn img {
  width: 40px;
  height: 40px;
}

.slide-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d8d8d8;
  font-size: 14px;
  font-weight: 500;
}

.slide-select {
  max-width: min(300px, 34vw);
  height: 30px;
  padding: 0 28px 0 10px;
  border: 1px solid rgba(184, 184, 184, 0.34);
  border-radius: 6px;
  background: #050505;
  color: #d8d8d8;
  font-size: 14px;
  font-weight: 500;
}

.slide-select:disabled {
  opacity: 0.55;
}

.slide-nav {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
}

.round-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
}

.session-debug {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(249, 176, 77, 0.45);
  border-radius: 8px;
  background: rgba(249, 176, 77, 0.07);
  color: #f2dfc4;
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  line-height: 1.25;
}

.session-debug[hidden] {
  display: none;
}

.debug-item {
  min-width: 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
}

.debug-label {
  display: block;
  margin-bottom: 3px;
  color: rgba(249, 176, 77, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.debug-value {
  display: block;
  overflow: hidden;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-wide {
  grid-column: span 2;
}

.debug-action-btn {
  width: 100%;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid rgba(249, 176, 77, 0.42);
  border-radius: 6px;
  background: rgba(249, 176, 77, 0.1);
  color: #fff3de;
  font: inherit;
  text-align: center;
}

.debug-action-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.chat-panel {
  min-height: 0;
  border: 1px solid var(--line);
  padding: 24px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 20px;
  background: #000;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
}

.chat-header img {
  width: 142px;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.chat-feed {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 6px;
}

.chat-feed::-webkit-scrollbar {
  width: 6px;
}

.chat-feed::-webkit-scrollbar-thumb {
  background: rgba(249, 176, 77, 0.45);
  border-radius: 999px;
}

.chat-message {
  width: fit-content;
  max-width: 86%;
  padding: 10px 16px;
  border-radius: 6px;
  color: #fff;
  font-size: 16px;
  line-height: 1.26;
  letter-spacing: 0.01em;
}

.chat-message-r2 {
  align-self: flex-start;
  background: var(--r2-message);
}

.chat-message-user {
  align-self: flex-end;
  background: var(--user-message);
}

.chat-message-system {
  align-self: center;
  max-width: 92%;
  background: rgba(249, 176, 77, 0.18);
  border: 1px solid rgba(249, 176, 77, 0.5);
  color: #f7f5f1;
  font-size: 14px;
  font-style: italic;
}

.chat-composer {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 16px;
  border-radius: 7px;
  background: var(--user-message);
  overflow: hidden;
}

.chat-composer textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 46px;
  max-height: 83px;
  padding: 13px 0 10px;
  border: 0;
  resize: none;
  outline: none;
  overflow: hidden;
  background: transparent;
  color: #fff;
  font-size: 16px;
  line-height: 20px;
}

.chat-composer textarea::placeholder {
  color: #969696;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

/* While the avatar is speaking, Send and Push to Talk are disabled. Let hover
   fall through the disabled buttons to the wrapper so the explanatory tooltip
   (set via data-tooltip) can appear, and lift the composer's clipping so it is
   not cut off. */
.chat-composer.shows-actions-hint {
  overflow: visible;
}

.chat-actions[data-tooltip] button:disabled {
  pointer-events: none;
}

.chat-actions[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 40;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(184, 184, 184, 0.28);
  background: rgba(0, 0, 0, 0.95);
  color: #e7e7e7;
  font-size: 12px;
  line-height: 1.4;
  white-space: normal;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-actions[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.mic-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.mic-btn span {
  display: none;
}

.send-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
}

.media-sink {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.media-sink video {
  width: 1px;
  height: 1px;
}

.menu-corner {
  position: relative;
  z-index: 40;
  display: inline-flex;
  align-items: center;
}

.menu-corner[hidden] {
  display: none;
}

.menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid rgba(184, 184, 184, 0.34);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #b8b8b8;
  font-family: "Space Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.72;
  cursor: pointer;
  transition: opacity 0.16s ease, color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.menu-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(213px, calc(100vw - 24px));
  max-height: min(74vh, 600px);
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(184, 184, 184, 0.28);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  overflow-x: hidden;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.menu-corner.is-open .menu-trigger,
.menu-trigger:hover,
.menu-trigger:focus-visible {
  opacity: 1;
  color: #e7e7e7;
  border-color: rgba(231, 231, 231, 0.54);
  background: rgba(255, 255, 255, 0.08);
}

.menu-corner.is-open .menu-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.menu-section {
  display: grid;
  gap: 8px;
}

.menu-section[hidden] {
  display: none;
}

.menu-item {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(184, 184, 184, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: #efe8dc;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: opacity 0.16s ease, color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.menu-item[hidden] {
  display: none;
}

.menu-item:hover,
.menu-item:focus-visible {
  border-color: rgba(231, 231, 231, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.menu-item-value {
  margin-left: 12px;
  color: #b8b8b8;
  font-size: 12px;
  font-weight: 700;
}

.language-list {
  display: none;
  grid-template-columns: 1fr;
  gap: 6px;
}

.menu-section.is-open .language-list {
  display: grid;
}

.language-option {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(249, 176, 77, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: #efe8dc;
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
}

.language-option[aria-pressed="true"] {
  border-color: rgba(249, 176, 77, 0.72);
  background: rgba(249, 176, 77, 0.13);
  color: #fff;
}

.language-list,
.sas-panel,
.presentation-panel {
  display: none;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(184, 184, 184, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.menu-section.is-open .language-list,
.menu-section.is-open .sas-panel,
.menu-section.is-open .presentation-panel {
  display: grid;
}

.sas-panel h2 {
  margin: 0;
  color: #efe8dc;
  font-size: 14px;
  font-weight: 700;
}

.sas-field {
  display: grid;
  gap: 4px;
  color: #b8b8b8;
  font-size: 12px;
}

.sas-field input {
  height: 32px;
  padding: 0 8px;
  border: 1px solid rgba(184, 184, 184, 0.34);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #efe8dc;
  font-size: 13px;
}

.sas-field select {
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid rgba(184, 184, 184, 0.34);
  border-radius: 6px;
  background: #050505;
  color: #d8d8d8;
  font-size: 14px;
  font-weight: 500;
}

.sas-field select option {
  background: #050505;
  color: #d8d8d8;
}

.sas-generate-btn,
.sas-copy-btn {
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(249, 176, 77, 0.5);
  border-radius: 6px;
  background: rgba(249, 176, 77, 0.13);
  color: #fff;
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sas-generate-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.sas-result {
  display: flex;
  gap: 6px;
}

.sas-result[hidden] {
  display: none;
}

.sas-result input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(184, 184, 184, 0.34);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #efe8dc;
  font-size: 12px;
}

.sas-error {
  margin: 0;
  min-height: 14px;
  color: #f9b04d;
  font-size: 12px;
}

.sas-error:empty {
  display: none;
}

/* Desktop: an expanded sub-section opens as a flyout window to the right of the
   menu instead of pushing content down inside the menu panel. */
@media (min-width: 721px) {
  .menu-panel {
    overflow: visible;
  }

  .menu-section {
    position: relative;
  }

  .menu-section.is-open .language-list,
  .menu-section.is-open .sas-panel,
  .menu-section.is-open .presentation-panel {
    position: absolute;
    left: calc(100% + 20px);
    /* Anchor to the bottom so the flyout grows upward and never extends past the
       bottom of the page (which would stretch the document and force scrolling). */
    bottom: 0;
    top: auto;
    z-index: 10;
    width: 300px;
    max-height: min(70vh, 520px);
    padding: 14px;
    border: 1px solid rgba(184, 184, 184, 0.28);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(12px);
    overflow-x: hidden;
    overflow-y: auto;
  }
}

.site-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  color: #e7e7e7;
  font-size: 14px;
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.footer-meta > span {
  color: #b8b8b8;
}

.footer-copy {
  grid-column: 2;
  justify-self: center;
  white-space: nowrap;
  color: #b8b8b8;
}

.site-footer nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.social-links {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
}

.social-links img {
  display: block;
  width: 19px;
  height: 19px;
  object-fit: contain;
}

@media (max-width: 1180px) {
  :root {
    --app-width: min(calc(100% - 40px), 960px);
    --app-height: auto;
    --presentation-max-width: 100%;
  }

  .app-shell {
    height: auto;
    min-height: 0;
    margin: 24px auto;
  }

  .experience,
  .site-footer {
    grid-template-columns: 1fr;
  }

  .experience {
    justify-content: stretch;
  }

  .chat-panel {
    height: 520px;
    height: min(640px, max(420px, calc(100svh - 48px)));
    min-height: 0;
  }

  .stage-frame {
    aspect-ratio: 16 / 9;
    height: auto;
  }

  .avatar-dock {
    right: -9%;
    bottom: 0%;
    width: 38%;
  }

  .site-footer,
  .site-footer nav,
  .social-links {
    justify-items: start;
    justify-self: start;
  }

  .footer-copy {
    grid-column: 1 / -1;
    justify-self: stretch;
    text-align: center;
    white-space: normal;
  }

  .site-footer nav {
    flex-wrap: wrap;
    gap: 16px 24px;
  }
}

@media (max-width: 720px) {
  :root {
    --app-width: calc(100% - 24px);
    --phone-shell-top: 5px;
    --phone-chat-panel-height: 320px;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    margin-top: var(--phone-shell-top);
    padding: 0 0 20px;
    gap: 14px;
  }

  .presentation-area {
    display: contents;
  }

  .experience {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .stage-frame {
    position: sticky;
    top: var(--phone-shell-top);
    z-index: 30;
    background: #000;
  }

  .avatar-dock {
    width: 46%;
  }

  .presentation-controls {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "start nav"
      "select select";
    align-items: center;
    gap: 12px;
  }

  .start-btn {
    grid-area: start;
    justify-self: start;
  }

  .slide-counter {
    grid-area: select;
    justify-self: stretch;
  }

  .slide-nav {
    grid-area: nav;
    justify-self: end;
    justify-content: flex-end;
  }

  .slide-select {
    width: 100%;
    max-width: none;
  }

  .session-debug {
    grid-template-columns: 1fr 1fr;
  }

  .debug-wide {
    grid-column: span 2;
  }

  .chat-panel {
    width: 100%;
    height: var(--phone-chat-panel-height);
    min-height: 0;
    padding: 18px;
  }

  .site-footer {
    width: 100%;
    gap: 16px;
    font-size: 14px;
  }

  .footer-meta {
    flex-wrap: wrap;
    gap: 16px;
  }

  body.smartphone-input-focused .site-footer {
    display: none;
  }

  body.smartphone-input-focused .app-shell {
    padding-bottom: var(--phone-shell-top);
  }

  .chat-message {
    max-width: 94%;
    font-size: 15px;
  }

  /* The SAS form expands inline inside the menu on smartphones, so the panel
     needs the original wider width to avoid clipping its contents. */
  .menu-panel {
    width: min(320px, calc(100vw - 24px));
  }
}

/* --- Site chrome --- */

body.site-chrome {
  /* Deterministic chrome heights so the app shell can shrink to keep the
     whole page inside the viewport on desktop. */
  --r2ch-header-h: 118px;
  --r2ch-footer-h: 56px;
  /* Tight, uniform vertical breathing room (header↔app, app↔footer, footer↔edge)
     so the footer drops close to the bottom edge and the reclaimed space goes
     to the stage instead of a dead gap under the footer. */
  --r2ch-vgap: clamp(10px, 1.8vh, 18px);
}

/* The app's own footer (Menu + Verizon copyright) is replaced by the merged
   site-chrome footer: the Menu button is relocated into .r2ch-footer and the
   in-shell footer is hidden, so its grid row collapses to a single content row. */
body.site-chrome .site-footer {
  display: none;
}

body.site-chrome .app-shell {
  grid-template-rows: minmax(0, 1fr);
}

@media (min-width: 1181px) {
  /* The base layout sizes .app-shell to the full viewport; subtract the
     chrome so header + app + footer fit without scrolling. Header sits flush
     at the top; three uniform --r2ch-vgap gaps (header↔app, app↔footer,
     footer↔edge) sum exactly, so nothing is wasted below the footer.
     Redeclared on body (not :root) so the ≤1180px :root override still wins. */
  body.site-chrome {
    --app-height: calc(100vh - var(--r2ch-header-h) - var(--r2ch-footer-h) - var(--r2ch-vgap) * 3);
    --presentation-max-width: calc((var(--app-height) - var(--footer-height) - 24px - 52px) * 16 / 9);
  }

  body.site-chrome .app-shell {
    margin-block: var(--r2ch-vgap);
  }

  /* Drops the footer to sit one small gap above the bottom edge. */
  body.site-chrome .r2ch-footer {
    margin-bottom: var(--r2ch-vgap);
  }
}

.r2ch-header,
.r2ch-footer {
  font-family: "Poppins", sans-serif;
  color: #fff;
  background: var(--black);
}

.r2ch-header .r2ch-content,
.r2ch-footer .r2ch-content {
  width: var(--app-width);
  max-width: 1450px;
  margin-inline: auto;
}

/* --- Header --- */

.r2ch-header {
  position: relative;
  z-index: 40;
}

/* 3-column grid keeps the nav centered in the full header width regardless of
   the logo's width. Explicit grid-column placement means the hidden hamburger
   (desktop) / hidden nav (≤930px) leaves its track empty instead of reflowing,
   so logo stays left and hamburger stays right at every width. */
.r2ch-header .r2ch-content {
  height: var(--r2ch-header-h, 118px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.r2ch-logo {
  grid-column: 1;
  justify-self: start;
}

.r2ch-nav {
  grid-column: 2;
  justify-self: center;
}

.r2ch-menu-btn {
  grid-column: 3;
  justify-self: end;
}

.r2ch-logo img {
  display: block;
  width: 139px;
  max-width: 100%;
  height: auto;
}

.r2ch-list {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  list-style: none;
  column-gap: 30px;
  position: relative;
}

.r2ch-item {
  position: relative;
}

.r2ch-link {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  text-decoration: none;
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}

.r2ch-link:hover {
  color: #f9b04d;
}

.r2ch-arrow {
  padding-left: 5px;
  padding-bottom: 2px;
}

.r2ch-sublist {
  position: absolute;
  left: 0;
  top: 100%;
  margin: 10px 0 0;
  display: block;
  background-color: #1e1e1e;
  padding: 16px;
  border-radius: 20px;
  width: 250px;
  list-style: none;
  text-align: left;
}

/* Author display:block above overrides the UA [hidden] rule, so restore it. */
.r2ch-sublist[hidden] {
  display: none;
}

.r2ch-subitem a {
  display: flex;
  align-items: center;
  column-gap: 8px;
  width: 100%;
  padding-bottom: 10px;
  color: #fff;
  font-size: 14px;
  text-decoration: none;
}

.r2ch-subitem:last-child a {
  padding-bottom: 0;
}

.r2ch-subitem a:hover {
  color: #f9b04d;
}

.r2ch-subitem img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* Mobile hamburger (mirrors the source site's ≤930px behavior). */

.r2ch-menu-btn {
  display: none;
  width: 30px;
  height: 30px;
  position: relative;
  z-index: 10;
  padding: 0;
  border: 0;
  background: none;
}

.r2ch-menu-btn span {
  width: 30px;
  height: 2px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: #fff;
  transition: all 0.3s;
}

.r2ch-menu-btn span:nth-of-type(1) {
  top: calc(50% - 10px);
}

.r2ch-menu-btn span:nth-of-type(3) {
  top: calc(50% + 10px);
}

.r2ch-menu-btn[aria-expanded="true"] span:nth-of-type(1) {
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
}

.r2ch-menu-btn[aria-expanded="true"] span:nth-of-type(2) {
  opacity: 0;
}

.r2ch-menu-btn[aria-expanded="true"] span:nth-of-type(3) {
  top: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.r2ch-mobile-menu {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(330px, 100vw);
  height: 100dvh;
  overflow-y: auto;
  background-color: #1e1e1e;
  box-shadow: -44px 0 57px 2px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  padding: 72px 16px 16px;
  text-align: center;
}

.r2ch-mobile-menu[hidden] {
  display: none;
}

.r2ch-mobile-items {
  margin: 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  row-gap: 20px;
  list-style: none;
}

.r2ch-mobile-link {
  color: #fff;
  font-size: 24px;
  text-decoration: none;
  cursor: pointer;
}

.r2ch-mobile-link:hover {
  color: #f9b04d;
}

.r2ch-mobile-sub {
  margin: 0;
  padding: 10px 0 0;
  list-style: none;
}

.r2ch-mobile-sub a {
  display: flex;
  align-items: center;
  justify-content: center;
  column-gap: 8px;
  padding-bottom: 10px;
  color: #fff;
  font-size: 16px;
  text-decoration: none;
}

.r2ch-mobile-sub img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

@media (max-width: 930px) {
  .r2ch-nav {
    display: none;
  }

  .r2ch-menu-btn {
    display: block;
  }

  .r2ch-header .r2ch-content {
    height: auto;
    padding-block: 16px;
  }
}

/* --- Footer --- */

.r2ch-footer {
  padding-top: 12px;
}

.r2ch-copyright {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

/* Bottom-left cluster: the relocated Menu button + the copyright beside it. */
.r2ch-footer-left {
  display: flex;
  align-items: center;
  gap: 40px;
  min-width: 0;
}

.r2ch-copy {
  margin: 0;
  font-weight: 500;
  color: #a5a5a5;
  font-size: 12px;
}

.r2ch-footer-list {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  list-style: none;
  column-gap: 30px;
  flex-wrap: wrap;
}

.r2ch-footer-list a {
  text-decoration: none;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

.r2ch-footer-list a:hover {
  color: #f9b04d;
}

.r2ch-socials {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: 16px;
}

.r2ch-socials img {
  display: block;
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .r2ch-footer-list {
    width: 100%;
    order: 1;
    padding: 20px 0;
    justify-content: center;
  }

  .r2ch-socials {
    order: 0;
    width: 100%;
  }

  .r2ch-footer-left {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .r2ch-copyright {
    justify-content: center;
  }
}

@media (max-width: 720px) {
  body.smartphone-input-focused .r2ch-footer,
  body.smartphone-input-focused .r2ch-header {
    display: none;
  }
}
