:root {
  --background: var(--color-bg);
  --foreground: var(--color-fg);
  --translucent-bg: var(--color-bg-trans);
  --theme: var(--color-theme);
  --theme-hover: var(--color-theme-hover);
  --bubble-theme: #00CDFF;
  --radius: 1.5em;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0px;
  padding: 0px;
  display: grid;
  grid-template: auto repeat(2, 1fr) / auto repeat(2, 1fr);

}
header {
  margin: 1em;
  padding: 2em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75em;
  background: var(--translucent-bg);
  grid-row: 1 / 2;
  grid-column: 1 / 2;
  backdrop-filter: blur(30px);
  border-radius: var(--radius);
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.3s ease;
}

header.hidden {
  opacity: 0;
  pointer-events: none;
}

.menu-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--foreground);
  opacity: 0.7;
  text-align: center;
}

.privacy-link {
  font-size: 0.75rem;
  color: var(--foreground);
  opacity: 0.7;
  text-align: center;
}
.privacy-link:hover {
  opacity: 1;
}

.pill-button {
  display: inline-block;
  align-self: stretch;
  background: var(--theme);
  color: var(--foreground);
  padding: 0.7em 1.5em;
  border-radius: 2em;
  border: 2px solid var(--bubble-theme);
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  text-align: center;
  transition: background 0.2s;
}
.pill-button:hover {
  background: var(--theme-hover);
}
.file-label input[type="file"] {
  display: none;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75em;
  height: 2.75em;
  padding: 0;
  background: var(--theme);
  color: var(--foreground);
  border-radius: 50%;
  border: 2px solid var(--bubble-theme);
  cursor: pointer;
  transition: background 0.2s;
}
.icon-button[hidden] {
  display: none;
}
.icon-button:hover {
  background: var(--theme-hover);
}
.icon-button svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
main {
  width: 100%;
  height: 100dvh;
  grid-row: 1 / -1;
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--background);
}
a-scene {
  width: 100dvw;
  height: 100dvh;
  background: var(--background);
}
@media (max-width: 768px) {
  body {
    grid-template: 1fr 1fr auto / 1fr;
  }

  header {
    grid-row: 3 / -1;
    grid-column: 1 / -1;
    margin: 0.7em;
    padding: 1em;
    flex-direction: column;
    justify-content: center;
  }

  .pill-button {
    padding: 0.6em 1.2em;
    font-size: 0.9rem;
  }

  .icon-button {
    width: 2.4em;
    height: 2.4em;
  }

}

@media (max-width: 480px) {
  header {
    margin: 0.25em;
    padding: 0.75em;
  }

  .pill-button {
    padding: 0.5em 1em;
    font-size: 0.85rem;
  }

  .icon-button {
    width: 2.2em;
    height: 2.2em;
  }
}

/* window-controls-overlay: hides the OS titlebar only. Layout (header, menu) is unchanged;
   #wcoTitlebar is an invisible strip spanning the reclaimed titlebar area, and the header itself
   is also made draggable, so the now-title-bar-less window can still be moved from either. Buttons
   and the file-select label opt back out of the drag so they stay clickable. Unsupported browsers
   never match this query, so the normal header/titlebar above is the fallback. */
#wcoTitlebar {
  display: none;
}

@media (display-mode: window-controls-overlay) {
  #wcoTitlebar {
    display: block;
    position: fixed;
    top: env(titlebar-area-y, 0);
    left: env(titlebar-area-x, 0);
    width: env(titlebar-area-width, 100%);
    height: env(titlebar-area-height, 33px);
    -webkit-app-region: drag;
    app-region: drag;
    z-index: 9998;
  }

  header {
    -webkit-app-region: drag;
    app-region: drag;
  }

  header .pill-button,
  header .icon-button,
  header .file-label {
    -webkit-app-region: no-drag;
    app-region: no-drag;
  }
}

/* offline.html fallback page */
body.offline-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  text-align: center;
  background: var(--background);
  color: var(--foreground);
}

body.offline-page main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1em;
  padding: 2em;
  max-width: 26em;
}

body.offline-page button#retry {
  background: var(--theme);
  color: var(--foreground);
  border: 2px solid var(--bubble-theme);
  border-radius: 2em;
  padding: 0.7em 1.5em;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

body.offline-page button#retry:hover {
  background: var(--theme-hover);
}

/* privacy.html */
body.privacy-page {
  display: block;
  min-height: 100dvh;
  background: var(--background);
  color: var(--foreground);
}

body.privacy-page main {
  display: flex;
  justify-content: center;
  height: auto;
  padding: 2em 1em 4em;
}

body.privacy-page article {
  width: 100%;
  max-width: 40em;
  line-height: 1.5;
}

body.privacy-page h1 {
  margin-top: 0.5em;
}

body.privacy-page a {
  color: var(--foreground);
}

/* demo gallery: bottom sheet */
.gallery-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10000;
}

.gallery-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.gallery-panel {
  width: 100%;
  max-width: 45em;
  max-height: 75vh;
  overflow-y: auto;
  background: var(--translucent-bg);
  backdrop-filter: blur(30px);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5em;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.gallery-overlay.open .gallery-panel {
  transform: translateY(0);
}

.gallery-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1em;
}

.gallery-panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--foreground);
}

.gallery-close {
  background: none;
  border: none;
  color: var(--foreground);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25em;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9em, 1fr));
  gap: 0.75em;
}

.gallery-item {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  background: none;
  border: 2px solid transparent;
  border-radius: 1em;
  padding: 0.4em;
  cursor: pointer;
  font: inherit;
  color: var(--foreground);
}

.gallery-item:hover,
.gallery-item:focus-visible {
  border-color: var(--bubble-theme);
  outline: none;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  border-radius: 0.75em;
}

.gallery-item span {
  font-size: 0.85rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .gallery-overlay,
  .gallery-panel,
  header {
    transition: none;
  }
}