:root {
  color-scheme: dark;
  --bg: #06070a;
  --glass: rgba(13, 16, 23, 0.66);
  --glass-strong: rgba(20, 24, 33, 0.82);
  --line: rgba(255, 255, 255, 0.12);
  --line-bright: rgba(255, 255, 255, 0.22);
  --text: #f5f7fb;
  --muted: #a7afbd;
  --soft: #d8dee8;
  --accent: #8ee8df;
  --accent-2: #d6b56d;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 75% 18%, rgba(142, 232, 223, 0.12), transparent 28%),
    radial-gradient(circle at 16% 78%, rgba(214, 181, 109, 0.1), transparent 32%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  backdrop-filter: blur(18px);
}

button {
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  line-height: 1.15;
  overflow-wrap: normal;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

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

button:hover {
  border-color: var(--line-bright);
  background: rgba(255, 255, 255, 0.095);
  box-shadow: 0 0 24px rgba(142, 232, 223, 0.08);
}

button:active {
  transform: translateY(1px);
}

select {
  height: 38px;
  padding: 0 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 410px) 1fr;
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.auth-locked .app-shell {
  pointer-events: none;
  filter: blur(10px) brightness(0.55);
}

.glass-panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(18, 22, 31, 0.74), rgba(7, 9, 13, 0.54));
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(130%);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  padding: 18px;
  border-radius: 22px;
}

.brand-block h1 {
  margin: 6px 0 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.brand-block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.file-drop {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px dashed var(--line-bright);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-drop span {
  color: var(--accent);
  font-weight: 800;
}

.file-drop small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.panel-tabs button {
  min-height: 36px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: 12px;
  white-space: nowrap;
}

.panel-tabs button.is-active,
.preset-grid button.is-active,
.environment-card.is-active {
  border-color: rgba(142, 232, 223, 0.72);
  background: rgba(142, 232, 223, 0.13);
  box-shadow: inset 0 0 18px rgba(142, 232, 223, 0.08);
}

.panel-page {
  display: none;
  gap: 14px;
}

.panel-page.is-active {
  display: grid;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.material-list,
.editor-block,
.texture-grid,
.environment-list,
.preset-grid {
  display: grid;
  gap: 8px;
}

.empty-state {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
}

.material-button {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px 10px;
  text-align: left;
}

.material-button.is-active {
  border-color: rgba(214, 181, 109, 0.74);
  background: rgba(214, 181, 109, 0.11);
}

.material-swatch {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
}

.material-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-type {
  color: var(--muted);
  font-size: 11px;
}

.control-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--soft);
  font-size: 13px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  color: var(--soft);
  font-size: 13px;
}

.texture-grid {
  grid-template-columns: 1fr;
}

.texture-grid label {
  display: grid;
  gap: 5px;
  color: var(--soft);
  font-size: 12px;
}

.primary-button {
  border-color: transparent;
  background: linear-gradient(135deg, #8ee8df, #d6b56d);
  color: #07100f;
  font-weight: 900;
}

.secondary-button {
  color: var(--text);
}

.viewport-wrap {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
}

.topbar {
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 18px;
}

.topbar strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions button,
.top-actions select {
  flex: 0 0 auto;
}

.canvas-host {
  position: relative;
  overflow: hidden;
  min-height: 0;
  contain: layout size style;
  border: 1px solid var(--line);
  border-radius: 26px;
  background-color: transparent;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%);
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  background-size: 28px 28px;
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.34);
}

#sceneCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(142, 232, 223, 0.9);
  border-radius: 999px;
  background: rgba(142, 232, 223, 0.22);
  box-shadow: 0 0 0 0 rgba(142, 232, 223, 0.35);
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  animation: pulse 1.8s infinite;
}

.hotspot::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: inherit;
  background: var(--accent);
}

.hotspot-tooltip {
  position: absolute;
  left: 28px;
  top: 50%;
  display: none;
  width: 220px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 10, 15, 0.84);
  color: var(--muted);
  transform: translateY(-50%);
  backdrop-filter: blur(18px);
}

.hotspot:hover .hotspot-tooltip,
.hotspot.is-open .hotspot-tooltip {
  display: grid;
  gap: 5px;
}

.hotspot-tooltip strong {
  color: var(--text);
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 18px rgba(142, 232, 223, 0); }
  100% { box-shadow: 0 0 0 0 rgba(142, 232, 223, 0); }
}

.empty-overlay {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  gap: 10px;
  width: min(440px, calc(100% - 44px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(9, 11, 16, 0.72);
  color: var(--muted);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(24px);
}

.empty-overlay strong {
  color: var(--text);
  font-size: 20px;
}

.empty-overlay.is-hidden {
  display: none;
}

.variant-strip {
  display: flex;
  gap: 8px;
  overflow: auto;
  margin-top: 12px;
  padding: 10px;
  border-radius: 18px;
}

.variant-strip button {
  min-width: max-content;
  white-space: nowrap;
}

.environment-list {
  grid-template-columns: 1fr 1fr;
}

.environment-card {
  display: grid;
  gap: 8px;
  min-height: 82px;
  padding: 10px;
  text-align: left;
}

.environment-thumb {
  height: 32px;
  border-radius: 10px;
}

.preset-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preset-grid button,
.environment-card {
  min-width: 0;
  white-space: normal;
}

.loader-screen {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background: #050609;
}

.loader-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.auth-screen {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 74% 16%, rgba(142, 232, 223, 0.14), transparent 30%),
    radial-gradient(circle at 18% 82%, rgba(214, 181, 109, 0.14), transparent 34%),
    rgba(4, 5, 8, 0.92);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  display: grid;
  gap: 24px;
  width: min(980px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 28px;
  border-radius: 26px;
}

.auth-copy h1 {
  max-width: 650px;
  margin: 8px 0 10px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1;
}

.auth-copy p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(300px, 1.1fr);
  gap: 18px;
}

.auth-form,
.model-library {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.auth-mode {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.auth-mode button.is-active {
  border-color: rgba(142, 232, 223, 0.72);
  background: rgba(142, 232, 223, 0.13);
}

.link-button {
  min-height: auto;
  justify-self: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.link-button:hover {
  background: transparent;
  box-shadow: none;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--soft);
  font-size: 13px;
}

.auth-form input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-message[data-type="error"] {
  color: #ff9b9b;
}

.auth-message[data-type="success"] {
  color: var(--accent);
}

.library-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.library-item {
  display: grid;
  gap: 4px;
  min-height: 54px;
  padding: 10px 12px;
  text-align: left;
}

.library-item strong,
.library-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item span {
  color: var(--muted);
  font-size: 12px;
}

.library-item.is-active {
  border-color: rgba(214, 181, 109, 0.74);
  background: rgba(214, 181, 109, 0.11);
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
}

.account-row button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.admin-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-body {
  min-height: 100vh;
  overflow: auto;
}

.admin-console {
  display: grid;
  place-items: start center;
  min-height: 100vh;
  padding: 24px;
}

.admin-console .auth-card,
.admin-console .admin-panel {
  width: min(1180px, 100%);
}

.admin-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.admin-heading h1 {
  margin: 6px 0 0;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
}

.admin-heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.admin-login-form {
  max-width: 460px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-stats article {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.admin-stats strong {
  font-size: 24px;
}

.admin-stats span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-toolbar,
.admin-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.admin-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
}

.admin-toolbar input,
.admin-actions input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.admin-actions label {
  display: grid;
  gap: 6px;
  color: var(--soft);
  font-size: 13px;
}

.admin-user-list {
  display: grid;
  gap: 10px;
  max-height: 340px;
  overflow: auto;
}

.admin-user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.admin-user-card strong,
.admin-user-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-card span {
  color: var(--muted);
  font-size: 12px;
}

.admin-user-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 390px;
}

.admin-user-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.danger-button {
  border-color: rgba(255, 132, 132, 0.36);
  color: #ffb6b6;
}

.loader-card {
  display: grid;
  gap: 16px;
  width: min(430px, calc(100vw - 40px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(14, 17, 24, 0.74);
  box-shadow: var(--shadow);
}

.loader-card h1 {
  margin: 0;
}

.loader-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.loader-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

@media (max-width: 960px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(520px, 58vh) auto;
    height: auto;
    min-height: 100vh;
  }

  .panel {
    order: 2;
    max-height: none;
  }

  .viewport-wrap {
    order: 1;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
  }

  .panel-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .control-row {
    grid-template-columns: 88px 1fr;
  }

  .environment-list,
  .preset-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .admin-stats,
  .admin-toolbar,
  .admin-actions,
  .admin-user-card {
    grid-template-columns: 1fr;
  }

  .admin-user-actions {
    justify-content: stretch;
    max-width: none;
  }
}
