:root {
  color-scheme: dark;
  --ifc-bg: #020406;
  --ifc-panel: rgba(8, 15, 19, 0.84);
  --ifc-panel-solid: #081014;
  --ifc-cyan: #00e0ff;
  --ifc-cyan-soft: #8decf7;
  --ifc-text: #f4fbff;
  --ifc-muted: #9bb0bb;
  --ifc-border: rgba(0, 224, 255, 0.26);
  --ifc-danger: #ff8c8c;
  --ifc-success: #7cf2c1;
  --ifc-shadow: 0 18px 60px rgba(0, 0, 0, 0.52);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ifc-bg);
}

body {
  min-height: 100dvh;
  color: var(--ifc-text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
.file-button {
  -webkit-tap-highlight-color: transparent;
}

.viewer-app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  background:
    radial-gradient(circle at 70% 0%, rgba(0, 224, 255, 0.08), transparent 35%),
    var(--ifc-bg);
}

.viewer-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: calc(10px + env(safe-area-inset-top)) clamp(14px, 3vw, 28px) 10px;
  border-bottom: 1px solid var(--ifc-border);
  background: rgba(2, 6, 8, 0.88);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.viewer-brand,
.viewer-back,
.viewer-contact {
  color: var(--ifc-text);
  text-decoration: none;
}

.viewer-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.viewer-brand img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(0, 224, 255, 0.34);
}

.viewer-brand span {
  display: grid;
  min-width: 0;
}

.viewer-brand small {
  color: var(--ifc-cyan-soft);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  line-height: 1.15;
  text-transform: uppercase;
}

.viewer-brand strong {
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.viewer-back,
.viewer-contact {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #d8e6ec;
  font-size: 0.84rem;
  font-weight: 750;
}

.viewer-back:hover {
  border-color: var(--ifc-border);
  color: #fff;
}

.viewer-contact {
  color: var(--ifc-cyan-soft);
}

.viewer-contact:hover {
  border-color: var(--ifc-border);
  color: #fff;
}

.back-label-short {
  display: none;
}

.viewer-main,
.viewer-viewport {
  min-width: 0;
  min-height: 0;
}

.viewer-main {
  position: relative;
  overflow: hidden;
}

.viewer-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(0, 224, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 224, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 42%, rgba(0, 224, 255, 0.12), transparent 36%),
    #05080b;
  background-size: 36px 36px, 36px 36px, auto, auto;
  touch-action: none;
  user-select: none;
}

.viewer-viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: 0;
  touch-action: none;
}

.empty-state,
.loading-panel,
.drop-overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(22px, 5vw, 54px);
}

.empty-state[hidden],
.loading-panel[hidden],
.drop-overlay[hidden] {
  display: none;
}

.empty-card {
  width: min(560px, 100%);
  padding: clamp(24px, 5vw, 46px);
  border: 1px solid var(--ifc-border);
  border-radius: 26px;
  background: linear-gradient(155deg, rgba(11, 23, 29, 0.94), rgba(4, 9, 12, 0.84));
  box-shadow: var(--ifc-shadow), inset 0 1px rgba(255, 255, 255, 0.04);
  text-align: center;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.empty-mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border: 1px solid rgba(0, 224, 255, 0.42);
  border-radius: 22px;
  background: rgba(0, 224, 255, 0.08);
  color: var(--ifc-cyan);
  box-shadow: 0 0 36px rgba(0, 224, 255, 0.2);
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.empty-card h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.65rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.empty-card p {
  max-width: 430px;
  margin: 16px auto 0;
  color: var(--ifc-muted);
  font-size: clamp(0.95rem, 2vw, 1.06rem);
  line-height: 1.65;
}

.file-button,
.viewer-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 999px;
  font-weight: 850;
  cursor: pointer;
}

.file-button {
  margin-top: 24px;
  padding: 12px 22px;
  border: 1px solid var(--ifc-cyan);
  background: var(--ifc-cyan);
  color: #001014;
  box-shadow: 0 10px 30px rgba(0, 224, 255, 0.22);
}

.file-button:hover {
  background: #79f0ff;
}

.empty-card .control-hint {
  margin-top: 18px;
  color: #78909b;
  font-size: 0.78rem;
}

.mobile-hint {
  display: none;
}

.viewer-toolbar {
  position: absolute;
  z-index: 12;
  right: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 28px);
  padding: 8px;
  border: 1px solid var(--ifc-border);
  border-radius: 18px;
  background: var(--ifc-panel);
  box-shadow: var(--ifc-shadow);
  transform: translateX(50%);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

body:not(.has-model) .viewer-toolbar {
  display: none;
}

.viewer-toolbar .file-button {
  min-width: 128px;
  margin: 0;
  padding: 10px 18px;
}

.viewer-control {
  min-width: 112px;
  padding: 10px 17px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ifc-text);
}

.viewer-control:hover:not(:disabled) {
  border-color: var(--ifc-border);
  background: rgba(0, 224, 255, 0.1);
}

.viewer-control:disabled,
.file-button:has(input:disabled) {
  cursor: wait;
  opacity: 0.52;
}

.viewer-status-wrap {
  position: absolute;
  z-index: 11;
  top: 14px;
  left: 14px;
  display: grid;
  gap: 7px;
  max-width: min(460px, calc(100% - 28px));
  pointer-events: none;
}

.viewer-status,
.file-name {
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  background: rgba(3, 9, 12, 0.78);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: #cce0e8;
  font-size: 0.78rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.viewer-status[data-state="success"] {
  color: var(--ifc-success);
}

.viewer-status[data-state="error"] {
  border-color: rgba(255, 140, 140, 0.34);
  color: var(--ifc-danger);
}

.loading-panel {
  z-index: 15;
  background: rgba(1, 4, 6, 0.74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.loading-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--ifc-border);
  border-radius: 20px;
  background: var(--ifc-panel-solid);
  box-shadow: var(--ifc-shadow);
}

.loading-card strong {
  display: block;
  margin-bottom: 14px;
}

.progress-track {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--ifc-progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #00a8c2, var(--ifc-cyan));
  box-shadow: 0 0 18px rgba(0, 224, 255, 0.6);
  content: "";
  transition: width 180ms ease;
}

.drop-overlay {
  z-index: 18;
  border: 3px dashed rgba(0, 224, 255, 0.7);
  background: rgba(0, 18, 24, 0.86);
  color: #fff;
  font-size: clamp(1.4rem, 5vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  text-align: center;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

[data-thatopen-logo] {
  left: 14px !important;
  right: auto !important;
  bottom: 78px !important;
}

@media (max-width: 680px) {
  .viewer-header {
    min-height: 58px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .viewer-brand img {
    width: 34px;
    height: 34px;
  }

  .viewer-brand strong {
    font-size: 0.9rem;
  }

  .viewer-back,
  .viewer-contact {
    min-height: 40px;
    padding: 7px 11px;
    font-size: 0.76rem;
  }

  .empty-card {
    padding: 26px 20px;
    border-radius: 22px;
  }

  .empty-mark {
    width: 62px;
    height: 62px;
    margin-bottom: 18px;
  }

  .desktop-hint {
    display: none;
  }

  .mobile-hint {
    display: inline;
  }

  .viewer-toolbar {
    right: 12px;
    bottom: max(76px, calc(10px + env(safe-area-inset-bottom)));
    left: 12px;
    max-width: none;
    padding: 7px;
    transform: none;
  }

  .viewer-toolbar .file-button,
  .viewer-control {
    flex: 1 1 0;
    min-width: 0;
    min-height: 50px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .viewer-status-wrap {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .viewer-status,
  .file-name {
    width: 100%;
  }

  [data-thatopen-logo] {
    left: 10px !important;
    bottom: 144px !important;
    transform: scale(0.86);
    transform-origin: bottom left;
  }
}

@media (max-width: 390px) {
  .viewer-brand small {
    display: none;
  }

  .viewer-back {
    flex: 0 0 auto;
  }

  .back-label-long {
    display: none;
  }

  .back-label-short {
    display: inline;
  }
}

@media (max-width: 350px) {
  .viewer-contact {
    display: none;
  }

  .viewer-brand strong {
    overflow: visible;
    text-overflow: clip;
  }
}

@media (max-width: 680px) and (max-height: 640px) {
  .empty-state {
    place-items: start center;
    overflow-y: auto;
    padding: 52px 12px 82px;
  }

  .empty-card {
    padding: 19px 18px 20px;
    border-radius: 19px;
  }

  .empty-mark {
    width: 52px;
    height: 52px;
    margin-bottom: 12px;
    border-radius: 17px;
  }

  .empty-card h1 {
    font-size: 1.85rem;
  }

  .empty-card p {
    margin-top: 10px;
    font-size: 0.9rem;
    line-height: 1.48;
  }

  .empty-card .file-button {
    min-height: 44px;
    margin-top: 14px;
    padding: 9px 18px;
  }

  .empty-card .control-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
