:root {
    --bg: #ece8e2;
    --bg-panel: #f7f4ef;
    --bg-elevated: #ffffff;
    --ink: #1c1814;
    --ink-muted: #6b635a;
    --line: #d4cdc3;
    --accent: #c45f28;
    --accent-ink: #fff8f2;
    --danger: #b54336;
    --desk: #3a3a3a;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Manrope", system-ui, sans-serif;
  }
  
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
  
  html,
  body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
  }
  
  body {
    height: 100dvh;
    background:
      radial-gradient(ellipse 70% 45% at 15% 0%, #f5f1eb 0%, transparent 55%),
      radial-gradient(ellipse 55% 40% at 90% 100%, #e4dfd7 0%, transparent 50%),
      var(--bg);
  }
  
  .noise {
    pointer-events: none;
    position: fixed;
    inset: 0;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    z-index: 0;
  }
  
  .app {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
  }
  
  .panel {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    height: 100%;
    min-height: 0;
    padding: 1.25rem 1.35rem;
    overflow: hidden;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
    backdrop-filter: blur(8px);
  }
  
  .brand {
    flex-shrink: 0;
  }
  
  .brand-mark {
    margin: 0 0 0.2rem;
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
  }
  
  .brand h1 {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
  }
  
  .lede {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--ink-muted);
  }
  
  .block {
    flex-shrink: 0;
  }
  
  .block h2 {
    margin: 0 0 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  
  .upload {
    position: relative;
    display: grid;
    gap: 0.15rem;
    margin-bottom: 0.5rem;
    padding: 0.65rem 0.8rem;
    border: 1px dashed var(--line);
    border-radius: 2px;
    background: var(--bg-elevated);
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
  }
  
  .upload:last-child {
    margin-bottom: 0;
  }
  
  .upload:hover,
  .upload:focus-within {
    border-color: var(--accent);
    background: #fffaf5;
  }
  
  .upload input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
  }
  
  .upload-label {
    font-size: 0.88rem;
    font-weight: 600;
  }
  
  .upload-hint {
    font-size: 0.72rem;
    color: var(--ink-muted);
  }
  
  .upload-btn {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .dims {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }
  
  .dims label {
    display: grid;
    gap: 0.2rem;
    font-size: 0.68rem;
    color: var(--ink-muted);
  }
  
  .dims input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 2px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    font-size: 0.88rem;
  }
  
  .dims input:focus {
    outline: 1px solid var(--accent);
    border-color: var(--accent);
  }
  
  .note {
    margin: 0.55rem 0 0;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--ink-muted);
  }
  
  .note span {
    color: var(--ink);
    font-weight: 600;
  }
  
  .render {
    flex-shrink: 0;
    margin-top: auto;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 0;
    border-radius: 2px;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 140ms ease, filter 140ms ease;
  }
  
  .render:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
  }
  
  .render:active {
    transform: translateY(0);
  }
  
  .render:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
  }
  
  .status {
    flex-shrink: 0;
    min-height: 1.1rem;
    margin: 0;
    font-size: 0.78rem;
    color: var(--ink-muted);
  }
  
  .status.is-error {
    color: var(--danger);
  }
  
  .stage {
    position: relative;
    display: grid;
    grid-template-rows: 1fr auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background:
      linear-gradient(180deg, #f3efe9 0%, #e8e3db 100%),
      repeating-linear-gradient(
        90deg,
        transparent,
        transparent 47px,
        rgba(90, 84, 76, 0.08) 48px
      ),
      repeating-linear-gradient(
        0deg,
        transparent,
        transparent 47px,
        rgba(90, 84, 76, 0.08) 48px
      );
  }
  
  .viewport {
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  
  .orbit-hint {
    margin: 0;
    padding: 0.5rem 1rem 0.75rem;
    text-align: center;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  
  @media (max-width: 860px) {
    .app {
      grid-template-columns: 1fr;
      grid-template-rows: minmax(0, 42%) minmax(0, 58%);
    }
  
    .panel {
      border-right: 0;
      border-bottom: 1px solid var(--line);
      overflow-y: auto;
      overscroll-behavior: contain;
    }
  
    .lede {
      display: none;
    }
  
    .note {
      display: none;
    }
  }

  /* —— Device restriction —— */
  .device-blocked {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 100dvh;
    padding: 1.5rem;
  }

  .device-blocked[hidden] {
    display: none;
  }

  body.is-device-blocked .app,
  body.is-device-blocked .noise {
    display: none;
  }

  .device-blocked-card {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    width: 100%;
    max-width: 34rem;
    padding: 1.35rem 1.4rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg-elevated);
    box-shadow: 0 18px 48px rgba(28, 24, 20, 0.12);
  }

  .device-blocked-card__icon {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 999px;
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
  }

  .device-blocked-card__icon svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .device-blocked-card__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
  }

  .device-blocked-card__message {
    margin: 0.45rem 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ink-muted);
  }

  /* —— 3D install alert —— */
  .install-alert {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    place-items: center;
    padding: 1rem;
  }

  .install-alert:not([hidden]),
  body.install-alert-open .install-alert {
    display: grid;
  }

  .install-alert[hidden] {
    display: none !important;
  }

  .install-alert__scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.34);
  }

  .install-alert__panel {
    position: relative;
    z-index: 1;
    width: 420px;
    max-width: calc(100vw - 32px);
    padding: 22px 22px 18px;
    -webkit-font-smoothing: antialiased;
  }

  .install-alert__panel[data-os="macos"],
  .install-alert__panel[data-os="linux"] {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
    border-radius: 16px;
    background: rgba(44, 44, 46, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow:
      0 0 0 0.5px rgba(255, 255, 255, 0.1),
      0 24px 80px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    color-scheme: dark;
  }

  .install-alert__panel[data-os="windows"] {
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(0, 0, 0, 0.08);
    color-scheme: light;
  }

  .install-alert__row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
  }

  .install-alert__icon {
    flex-shrink: 0;
  }

  .install-alert__icon svg {
    display: block;
  }

  .install-alert__copy {
    flex: 1;
    min-width: 0;
    padding-top: 0.15rem;
  }

  .install-alert__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
  }

  .install-alert__body,
  .install-alert__hint {
    margin: 0.5rem 0 0;
    font-size: 13px;
    line-height: 18px;
  }

  .install-alert__panel[data-os="macos"] .install-alert__title,
  .install-alert__panel[data-os="linux"] .install-alert__title {
    color: #fff;
  }

  .install-alert__panel[data-os="macos"] .install-alert__body,
  .install-alert__panel[data-os="linux"] .install-alert__body {
    color: rgba(255, 255, 255, 0.96);
  }

  .install-alert__panel[data-os="macos"] .install-alert__hint,
  .install-alert__panel[data-os="linux"] .install-alert__hint {
    color: rgba(255, 255, 255, 0.78);
  }

  .install-alert__panel[data-os="windows"] .install-alert__title {
    color: #000;
  }

  .install-alert__panel[data-os="windows"] .install-alert__body {
    color: #1a1a1a;
  }

  .install-alert__panel[data-os="windows"] .install-alert__hint {
    color: #323130;
  }

  .install-alert__cmd {
    margin-top: 0.75rem;
    overflow: hidden;
    cursor: pointer;
  }

  .install-alert__panel[data-os="macos"] .install-alert__cmd,
  .install-alert__panel[data-os="linux"] .install-alert__cmd {
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.18);
  }

  .install-alert__panel[data-os="windows"] .install-alert__cmd {
    border-radius: 4px;
    background: #fafafa;
    border: 1px solid #605e5c;
  }

  .install-alert__cmd code {
    display: block;
    padding: 0.4rem 0.65rem;
    overflow: hidden;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 15px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .install-alert__panel[data-os="macos"] .install-alert__cmd code,
  .install-alert__panel[data-os="linux"] .install-alert__cmd code {
    color: #fff;
  }

  .install-alert__panel[data-os="windows"] .install-alert__cmd code {
    color: #000;
  }

  .install-alert__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }

  .install-alert__waiting {
    margin-right: auto;
    font-size: 11px;
  }

  .install-alert__waiting[hidden] {
    display: none;
  }

  .install-alert__panel[data-os="macos"] .install-alert__waiting,
  .install-alert__panel[data-os="linux"] .install-alert__waiting {
    color: rgba(255, 255, 255, 0.78);
  }

  .install-alert__panel[data-os="windows"] .install-alert__waiting {
    color: #323130;
  }

  .install-alert__copy-btn {
    height: 26px;
    padding: 0 0.9rem;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
  }

  .install-alert__panel[data-os="macos"] .install-alert__copy-btn,
  .install-alert__panel[data-os="linux"] .install-alert__copy-btn {
    border: 0;
    border-radius: 999px;
    background: #0a84ff;
    color: #fff;
  }

  .install-alert__panel[data-os="windows"] .install-alert__copy-btn {
    border: 1px solid #605e5c;
    border-radius: 4px;
    background: #fff;
    color: #000;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  }
