:root {
  color-scheme: dark;
  --panel-bg: rgba(16, 17, 19, 0.82);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text: #f8f7f3;
  --muted: #bdb7aa;
  --accent: #7dd3fc;
  --accent-warm: #f6c45f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  --safe-right: max(16px, env(safe-area-inset-right));
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

*::before,
*::after {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
}

::selection {
  background: transparent;
  color: inherit;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #111111;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  touch-action: none;
}

button {
  font: inherit;
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 100vh;
  background:
    radial-gradient(circle at 35% 20%, rgba(246, 196, 95, 0.08), transparent 32%),
    #111111;
}

#viewer {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
  cursor: grab;
  touch-action: none;
}

#viewer:active {
  cursor: grabbing;
}

.loading {
  position: fixed;
  left: 50%;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
  min-height: 44px;
  padding: 10px 14px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.2;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.loading[hidden] {
  display: inline-flex;
  opacity: 0;
  transform: translate(-50%, -48%);
  visibility: hidden;
}

.loading-mark {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent-warm);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.control-dock {
  position: fixed;
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  z-index: 10;
  display: grid;
  justify-items: end;
  gap: 10px;
  pointer-events: none;
}

.icon-button,
.settings-row {
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: var(--panel-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  pointer-events: auto;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(125, 211, 252, 0.58);
  background: rgba(21, 24, 28, 0.92);
}

.icon-button:active {
  transform: scale(0.96);
}

.icon-button svg,
.settings-row svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.settings-panel {
  display: grid;
  width: min(282px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: auto;
  backdrop-filter: blur(18px);
}

.settings-panel[hidden] {
  display: none;
}

.settings-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row:hover,
.settings-row:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.settings-row[aria-pressed="true"] svg {
  color: var(--accent);
}

.settings-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.setting-state {
  justify-self: end;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.settings-row[aria-pressed="true"] .setting-state {
  border-color: rgba(125, 211, 252, 0.38);
  color: #d8f3ff;
}

.slider-row {
  grid-template-rows: auto auto;
  row-gap: 8px;
  padding-block: 10px;
  cursor: default;
}

.slider-row input {
  grid-column: 2 / 4;
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.slider-row.is-disabled {
  opacity: 0.48;
}

.slider-row.is-disabled input {
  cursor: not-allowed;
}

.settings-socials {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.social-link {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: var(--text);
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.social-link:hover,
.social-link:focus-visible {
  border-color: rgba(125, 211, 252, 0.58);
  background: rgba(255, 255, 255, 0.08);
}

.social-link:active {
  transform: scale(0.96);
}

.social-link svg {
  width: 20px;
  height: 20px;
}

.social-link-x span {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 520px) {
  .icon-button {
    width: 52px;
    height: 52px;
  }

  .settings-row {
    min-height: 52px;
    padding-inline: 12px;
  }
}

@media (pointer: coarse) {
  .settings-row {
    min-height: 58px;
  }
}
